# Beginning OpenGL Using XCode 2.2

This topic is 3928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! I'm a student learning to be a programmer. I have aspirations in joining the game industry some day, and figured that learning OpenGL as early as I could would benefit me greatly. I came across NeHe in my search for a tutorial, and I'm interested in using them. However, when attempting to do lesson 1 to be sure everything was working well enough for me to begin to learn, I came across a problem. When attempting to build and run the program, it told me the following: (X)Undefined symbols: _DrawGLScene _InitGL _ReSizeGlScene _glutResizeFunc collect2: Id returned 1 exit status It seems like there is a header file missing, or a mistype of the functions (the latter of which I'm doubting). I have searched around, but was unable to find an answer elsewhere. Also the code was pretty much an exact copy that was provided in the NeHe tutorial. It is as follows Source: Lesson: Mac OS X
#include <OpenGL/gl.h>		// Header File For The OpenGL32 Library
#include <OpenGL/glu.h>		// Header File For The GLu32 Library
#include <GLUT/glut.h>		// Header File For The GLut Library

#define kWindowWidth	400
#define kWindowHeight	300

GLvoid InitGL(GLvoid);
GLvoid DrawGLScene(GLvoid);
GLvoid ReSizeGLScene(int Width, int Height);

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize (kWindowWidth, kWindowHeight);
glutInitWindowPosition (100, 100);
glutCreateWindow (argv[0]);

InitGL();

glutDisplayFunc(DrawGLScene);
glutReshapeFunc(ReSizeGLScene);

glutMainLoop();

return 0;
}

I am pretty decent with the C language (currently making my first version of a raytracing program for a class), to just give some background information. Also, I am running Mac OS X 10.4 Tiger and, as said in the subject, using XCode 2.2. Any information that can be given is greatly appreciated. Thank you very much for your time!

##### Share on other sites
I've never used Mac, but the linker errors you reported shouw that you didn't define the functions DrawGLScene,InitGL and ReSizeGlScene. Or perhaps you forgot to link to anoether file where you defined them?

Posible code for the three functions is (taken from NeHe lesson1):
GLvoid DrawGLScene(GLvoid)							// Here's Where We Do All The Drawing{	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);		        // Clear The Screen And The Depth Buffer	glLoadIdentity();	        glTranslatef(-1.5f,0.0f,-6.0f);		        glBegin(GL_TRIANGLES);						// Drawing Using Triangles		glVertex3f( 0.0f, 1.0f, 0.0f);				// Top		glVertex3f(-1.0f,-1.0f, 0.0f);				// Bottom Left		glVertex3f( 1.0f,-1.0f, 0.0f);				// Bottom Right	glEnd();	}GLvoid InitGL(GLvoid){        // Enable Smooth Shading	glShadeModel(GL_SMOOTH);	// Black Background	glClearColor(0.0f, 0.0f, 0.0f, 0.5f);	// Depth Buffer Setup	glClearDepth(1.0f);	// Enables Depth Testing	glEnable(GL_DEPTH_TEST);	// The Type Of Depth Testing To Do	glDepthFunc(GL_LEQUAL);	// Really Nice Perspective Calculations	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);}GLvoid ReSizeGLScene(int Width, int Height){        // Prevent Division By Zero	// This condition occurs when the window height is 0 or less. We simply	// pretend it has a hight of 1. The window will probably not be drawn.	if (Height<=0)	{		Height=1;	}	// Reset the current viewport.	glViewport(0,0,Width,Height);	// Select The Projection Matrix	glMatrixMode(GL_PROJECTION);	// Reset The Projection Matrix	glLoadIdentity();	// Calculate The Aspect Ratio Of The Window	gluPerspective(45.0f,(GLfloat)Width/(GLfloat)Height,0.1f,100.0f);	// Select The Modelview Matrix	glMatrixMode(GL_MODELVIEW);	// Reset The Modelview Matrix	glLoadIdentity();}

Hope that helps

##### Share on other sites
That fixed it. I didn't think to look in the other Lesson 1's for them... I knew they hadn't been defined but assumed that I was just overlooking a header file or that something was missing in one of my frameworks. Looks like I assumed wrong. :)

Thanks very much.

##### Share on other sites

This topic is 3928 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628653
• Total Posts
2984051

• 10
• 9
• 9
• 10
• 21