GLUT and OpenGL advice needed

Discussion in 'Mac Programming' started by prostuff1, Jan 11, 2008.

  1. prostuff1 macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #1
    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.
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    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?
     
  3. prostuff1 thread starter macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #4
    if by OSU you mean Ohio State then yes. Just out of curiosity how did you figure it out?? (besides the fact that the link i provided went to an OSU page)
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5
    I figured this line made it pretty obvious :)
    I live in Columbus and have friends and family who go/have gone there, but I don't, although I wish I did now...
     
  5. prostuff1 thread starter macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #6
    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!!
     
  6. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #7
    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.
     
  7. prostuff1 thread starter macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #8
    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.
     
  8. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #9
    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 :).
     
  9. prostuff1 thread starter macrumors 65816

    prostuff1

    Joined:
    Jul 29, 2005
    Location:
    Don't step into the kawoosh...
    #10
    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:

    PS thanks for the help
     

Share This Page