#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;
}
Beginning OpenGL Using XCode 2.2
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
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!
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?
The latter one is perhaps something GLUT needs, take a look at the Glut documentation about this function (just google).
Posible code for the three functions is (taken from NeHe lesson1):
Hope that helps
The latter one is perhaps something GLUT needs, take a look at the Glut documentation about this function (just google).
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement