#include <gl/glut.h>
void drawSub(void){
//color, dimensions, type
glColor3f(0.0,0.0,0.0);
//vertex, dimensions, type
glVertex3f(-0.5,-0.5,-3.0);
glColor3f(1.0,0.0,0.0);
glVertex3f(0.5,-0.5,-3.0);
glColor3f(0.0,0.0,1.0);
glVertex3f(0.5,0.5,-3.0);
}
void sSimResh(int x, int y){
if (y == 0 || x == 0) return; //Nothing is visible then, so return
//Set a new projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//Angle of view:40 degrees
//Near clipping plane distance: 0.5
//Far clipping plane distance: 20.0
gluPerspective(40.0,(GLdouble)x/(GLdouble)y,0.5,20.0);
glMatrixMode(GL_MODELVIEW);
glViewport(0,0,x,y); //Use the whole window for rendering
}
void sSimDisp(void){
//clear the color buffer
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
//start drawing stuff
glBegin(GL_POLYGON);
drawSub();
//close rendering stuff
glEnd();
glFlush();
}
int main(int argc, char **argv) {
//initialize GLUT
glutInit(&argc, argv);
//display mode: color index/RGB, 1x/2x buffering
glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);
//window size
glutInitWindowSize(300,400);
glutCreateWindow("Main Window");
//assign a clear color (R,G,B,alpha)
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
//required functions
glutDisplayFunc(sSimDisp);
glutReshapeFunc(sSimResh);
//let GLUT do things
glutMainLoop();
//loop forever
return 0;
}
All fine and good. In the linker section of the project, I have (under -l): glu32, user32, freeglut and opengl32. Eclipse doesn't tell me it's having any problems finding said libraries, so I assumed I was good to roll (includes checked out fine too). Despite this, i'm getting linker errors (undefined reference to `_imp__glutMainLoop@0' etc).
I know my choice of IDE is less than ideal, but I use it for everything else from Java to Python, so I really don't want to install another one, though I hear the whole OpenGL deal is much smoother on VS. I'm hoping it's something I'm doing wrong as opposed to the source code needing fixing like it did earlier when I tried to build the SDK...