Hi,
Has anyone managed to get GLUT running with Dev-C++?
The source below compiles but the linker spits out errors...
//Source...
#include <gl\glut.h>
#include <gl\gl.h>
static void idleFunc(void)
{
glutPostRedisplay();
}
static void reshapeFunc(int width, int height)
{
glViewport(0, 0, width, height);
//set up viewport
glMatrixMode(GL_PROJECTION);
//projection matrix
glLoadIdentity();
//set up frustrum
gluPerspective(45, (GLdouble) width / height, 1, 150);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0.0, 0.0, -15.0);
}
static void keyboardFunc(unsigned char key, int x, int y)
{
switch(key) {
case 27:
//escape key
exit(0);
break;
case '\r':
//enter key
break;
}
glutPostRedisplay();
}
void initFunc(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glClearDepth(1.0);
glShadeModel(GL_FLAT);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ZERO);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
}
static void displayFunc(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
//save modelview matrix
glBegin( GL_TRIANGLES );
glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f );
//draw polygon
glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f );
glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f );
glEnd();
glPopMatrix();
//restore modelview
glutSwapBuffers();
//flip buffers
}
int main(int argc, char **argv)
{
glutInit(&argc, argv);
//Init display mode
glutInitWindowSize(600, 400);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
glutCreateWindow(argv[0]);
initFunc();
//InitOGL
glutKeyboardFunc(keyboardFunc);
glutReshapeFunc(reshapeFunc);
glutDisplayFunc(displayFunc);
glutIdleFunc(idleFunc);
glutMainLoop();
//never returns
return 0;
}
-----------------------
The Linker reports...
c:\my documents\gluttest.o(.text+0x1d):gluttest.cpp: undefined reference
to `__glutInitWithExit'
c:\my documents\gluttest.o(.text+0x32):gluttest.cpp: undefined reference
to `glutInitWindowSize'
c:\my documents\gluttest.o(.text+0x3c):gluttest.cpp: undefined reference
to `glutInitDisplayMode'
c:\my documents\gluttest.o(.text+0x4e):gluttest.cpp: undefined reference
to `__glutCreateWindowWithExit'
[...]
Any help greatly appreciated.
TIA
Clive
|