PDA

View Full Version : OpenGL q's


Duane
2004.10.03, 11:53 AM
I have a dilemma. I used the NeHe OpenGL tutorials, and I can't even create a window. in main.c, i used ZeroLink, and it built fine, but quit on start. i disabled ZeroLink, and it returned a warning an an error:
opengl mainframe:0: Undefined symbols: _DrawGLScene _InitGL _ReSizeGLScene
opengl mainframe:0: warning prebinding disabled because of undefined symbols

BTW, here is the code:
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>
#include <GLUT/glut.h>
#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;
}

NCarter
2004.10.03, 01:09 PM
I'm not quite sure where you are with those tutorials, but if you're at the stage where you're just trying to get a window to appear, you're nearly there apart from the fact you haven't defined the functions. You've got prototypes, but you still need to add the following before your main() line:

GLvoid InitGL(GLvoid)
{
}

GLvoid DrawGLScene(GLvoid)
{
}

GLvoid ReSizeGLScene(int Width, int Height)
{
}
This code won't do anything much because there's no code in the functions, but it will eliminate your link errors.

EDIT: In case it isn't obvious, don't remove the prototypes when you insert the functions. You (usually) want both.

FCCovett
2004.10.03, 01:40 PM
Get the source code from http://webpages.charter.net/utopiaplanetia/BasicCarbonStruct.dmg

You may not understand all of it in the beginning, but it will show you how to create a window, play sounds, read mouse and keyboard, read and save preferences, load textures (PNG, TGA, JPG), all with Carbon, CoreAudio, and OpenGL.

Duane
2004.10.03, 02:08 PM
Cool. Thanx guys!

Duane
2004.10.04, 04:00 PM
new problem:
on lesson 2, it says, when I return TRUE, that TRUE is undeclared. Why?

AnotherJake
2004.10.04, 04:30 PM
Probably because it's not. Try "true" instead of "TRUE". You could also define it yourself by:
#define TRUE 1
#define FALSE 0

ThemsAllTook
2004.10.04, 06:07 PM
Personally, I never trust TRUE and FALSE to be defined. I always just use 1 and 0. Same difference.

Alex Diener

Duane
2004.10.04, 06:13 PM
ahh, I see. It's been A while since I used C, normally sticking with OBJ-C.
one more problem, (yes, i know). it runs fine, makes a triangle and a square, but thee window is automatically minimized. Any idea why?