GLUT includes?

Nibbie
Posts: 1
Joined: 2010.11
Post: #1
I have this example code from the "red book", ca someone "port" it to PB? I't probably really simple but I have no clue.
Code:
#include <GL/gl.h>
#include <GL/glut.h>
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw white polygon (rectangle) with corners at
* (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
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();
/* don't wait!
* start processing buffered OpenGL routines
*/
glFlush ();
}
void init (void)
{
/* select clearing (background) color */
glClearColor (0.0, 0.0, 0.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/*
* Declare initial window size, position, and display mode
* (single buffer and RGBA). Open window with "hello"
* in its title bar. Call initialization routines.
* Register callback function to display graphics.
* Enter main loop and process events.
*/
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; /* ISO C requires main to return int. */
}
Quote this message in a reply
Member
Posts: 57
Joined: 2002.04
Post: #2
First off, change #include <GL/gl.h> and #include <GL/glut.h> to #include <OpenGL/gl.h> and #include <GLUT/glut.h> . You'll then need to add the OpenGL and GLUT frameworks to your project; control-click on the "External Frameworks and Libraries" folder and choose "Add Frameworks...", then select OpenGL.framework and GLUT.framework. The GLUT framework also requires the libobjc library, so control-click on "External Frameworks and Libraries" again, choose "Add Files...", type "/usr/lib/" into the "Go To..." field, and add libobjc.A.dylib . You may need to clean the target before building the source.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #3
Quote:Linking /Users/josephduchesne/Desktop/polygons - tutorial one/build/polygons.app/Contents/MacOS/polygons (1 error, 1 warning)
ld: /usr/lib/crt1.o illegal reference to symbol: __objcInit defined in indirectly referenced dynamic library /usr/lib/libobjc.A.dylib

C is annoying Rasp
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Quote:Originally posted by Mazilurik
The GLUT framework also requires the libobjc library, so control-click on "External Frameworks and Libraries" again, choose "Add Files...", type "/usr/lib/" into the "Go To..." field, and add libobjc.A.dylib . You may need to clean the target before building the source.
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2010.11
Post: #5
It's working Grin . Thanks both of you. It makes sense know
Quote this message in a reply
Zoldar256
Unregistered
 
Post: #6
For cross platform development I usually bracket the Mac OS X include brew with:
[SOURCECODE]#if defined(__APPLE__) || defined(MACOSX) || defined(OSMac_)[/SOURCECODE]

So this way both the generic *nix and mac os x include code can be there.
Quote this message in a reply
Post Reply