Jump to content

  • Log In with Google      Sign In   
  • Create Account

OpenGL and Mac OS X.5


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 CBell   Members   -  Reputation: 122

Like
0Likes
Like

Posted 26 January 2008 - 07:10 AM

I'm using OS X and my OpenGL teacher uses Linux. One of the sources he sent the class won't work when I load it into Xcode. I found http://grammerjack.spaces.live.com/blog/cns!F2629C772A178A7C!200.entry which says to use Eclipse, but when I follow the directions on it, I still can't get the sample to work. Here is what it looks like. #include <GL/glut.h> void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); glBegin(GL_POLYGON); glVertex3f (0.25, 0.25, 0.0); glVertex3f (0.75, 0.25, 0.0); glVertex3f (0.75, 0.75, 0.0); glVertex3f (0.25, 0.75, 0.0); glEnd(); glFlush (); } void init (void) { glClearColor (0.0, 0.0, 0.0, 0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); glutInitWindowSize (250, 250); glutInitWindowPosition (100, 100); glutCreateWindow ("hello"); init (); glutDisplayFunc(display); glutMainLoop(); return 0; /* ANSI C requires main to return int. */ } I understand what it's doing, but it would be nice to actually run it. And be able to have my code work on his computer, so it can be graded. :) Also, sorry for not using any markups. I don't know what they are. I tried using <link=></link> and <code></code>, but when I previewed it, they didn't work.

Sponsor:

#2 szymczyk   Members   -  Reputation: 182

Like
0Likes
Like

Posted 26 January 2008 - 07:49 AM

You're using Xcode so you have to create a project and add the GLUT framework to the project. Your include of glut.h will not work on Mac OS X. You need to use the following include:

#include <GLUT/glut.h>

For step by step instructions on using GLUT with Xcode on Leopard, read the article at the following URL:

http://blog.onesadcookie.com/2007/12/xcodeglut-tutorial.html

Mark

#3 CBell   Members   -  Reputation: 122

Like
0Likes
Like

Posted 26 January 2008 - 08:00 AM

Thanks, man. That helped A LOT.


One last question, tho.

If I changed #include <GLUT/glut.h> to #include <GL/glut.h> before I turned in my program, would that be all I would have to change for it to work on his computer? I only have to hand in the source.

#4 szymczyk   Members   -  Reputation: 182

Like
0Likes
Like

Posted 26 January 2008 - 09:01 AM

Use the #if statement so you include GLUT the Mac way on a Mac and the Linux way on Linux. Here's an example.


#if __MACOSX__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif


For a GLUT program that doesn't load anything from a file, this would be all you would have to do for your code to work on your teacher's Linux computer.

#5 CBell   Members   -  Reputation: 122

Like
0Likes
Like

Posted 26 January 2008 - 09:53 AM

Thanks again.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS