Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

prostuff1

macrumors 65816
Original poster
Jul 29, 2005
1,482
18
Don't step into the kawoosh...
Just started a class and am looking for some input on the best way to go about setting up my mac so that I have as little trouble going back and forth between the windows machines on campus and mine here at home.

This class is just an intro class and for what we will be doing have been told that GLUT will work just fine.

The first "program" we have to mess with can be found here.

I am basically asking for suggestions on the easiest way to get programs like that above to work, without to much hassle.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Well the simplest way is to use Terminal to compile it, but you can also add it to a new Xcode project.

Either way, you need to make a small change in order for it to compile. Replace these lines:

Code:
#include <GL/glut.h>
#include <GL/gl.h>

With this:

Code:
#ifdef __APPLE__
#include <GLUT/glut.h>
#include <OpenGL/gl.h>
#else
#include <GL/glut.h>
#include <GL/gl.h>
#endif

That will allow the code to compile on Mac OS X and Windows.

To compile in Terminal (assuming the file is on your Desktop):

Code:
cd ~/desktop
g++ main.cpp -o main -framework OpenGL -framework GLUT

And then you can run it via

Code:
./main

However it didn't work for me on 10.5.1. There is something wrong with the recursive calls to fractal().

BTW, do you go to OSU?
 

prostuff1

macrumors 65816
Original poster
Jul 29, 2005
1,482
18
Don't step into the kawoosh...
Need some urgent Glut and opengl for dummies help.

NOTE: This is a lab assignment so if you don't want to help me out i understand, but some guidance would be great.

I linked to the lab that we have to do in the first post. Here are the instructions for the lab and the stuff we are supposed to do. I think my problems stem from no almost no C++. The other problem I was having was not being able to get this to run on my Mac and having to use my room mates PC (when he is not using it).

Anyway, guidance would be appreciated!!
 

Cromulent

macrumors 604
Oct 2, 2006
6,802
1,096
The Land of Hope and Glory
Need some urgent Glut and opengl for dummies help.

NOTE: This is a lab assignment so if you don't want to help me out i understand, but some guidance would be great.

I linked to the lab that we have to do in the first post. Here are the instructions for the lab and the stuff we are supposed to do. I think my problems stem from no almost no C++. The other problem I was having was not being able to get this to run on my Mac and having to use my room mates PC (when he is not using it).

Anyway, guidance would be appreciated!!

Mac OS X uses different includes. All you need to do is put the OpenGL and GLUT framework in your Xcode project and use the following for includes.

#include <GLUT/glut.h>
#include <math.h>
#include <string.h>

do not include gl.h as that is included in glut.h and the OpenGL programming guide specifically states that including both is a bad idea. That should get it running on Mac OS X.
 

prostuff1

macrumors 65816
Original poster
Jul 29, 2005
1,482
18
Don't step into the kawoosh...
Mac OS X uses different includes. All you need to do is put the OpenGL and GLUT framework in your Xcode project and use the following for includes.

#include <GLUT/glut.h>
#include <math.h>
#include <string.h>

do not include gl.h as that is included in glut.h and the OpenGL programming guide specifically states that including both is a bad idea. That should get it running on Mac OS X.

Thanks for the pointer on not including gl.h. I will test it out and see what happens.

But the main problem i am having is with the code period, i am just extremely lost, for some reason.
 

prostuff1

macrumors 65816
Original poster
Jul 29, 2005
1,482
18
Don't step into the kawoosh...
You mentioned C++ above when in fact the code you posted is just C.

It would help if you stated what you were stuck on :).

Yeah that might help.

I guess the two things i am trying to get my head around are getting the thing in color. We have to assign the color values (R=204, G=51, and B=153) to the fractal that is created.

I have a snippet of code i got from him that should work but I don't want to just use it without knowing how it works.

the code looks like this
Code:
img[framenum][(NS_WINSIZE + yc + xc) + 3 + 0]= 204;

I know this code will work as i saw it in his correct final solution but i just don't know how it works. And i would rather understand how it works before i go adding it to my code.


Anyway, the other thing that is puzzling me is how to store all the fractal images that are created. This is the main thing i would like to figure out, and i can mess with the color later.

i know i need to create a "precompute" function that will take the image created and store it in RAM so that i can go back through all of them later.

Basically this part is what concerns me the most right now:

# Pre-compute and store in main memory the entire sequence of frames before display

* Compute and store all frames of the animation in RAM once before you enter the event loop. Right now, the simple program stores only one frame in RAM at a time.
* You will not call the fractal function again after you have pre-computed all the frames
* When you want to display a frame simply access the appropriate frame from RAM and draw it to the frame buffer
* You should notice a considerable speedup in your program

PS thanks for the help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.