Hi, I’m using glut under Windows XP.
I have made a very basic program, which just initializes the window, and draws a rectangle. The program compiles and runs without a problem!
When I add keyboard or mouse callback functions, my program simply crashed. This is both the case using Visual C++ 6.0 and g++ under Cygwin.
I haven’t been able to find someone describing a similar problem on any of the forums I know of. I tried compiling on my friends WinXP machine - which also crashed.
Here is the code:
#include <windows.h>
#include <GL/glut.h>
void glInit() {
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(-10,10,-10,10);
glClearColor(0,0,0,1);
glColor3f(1,1,1);
}
void display() {
glClear(GL_COLOR_BUFFER_BIT);
glRectf(1,1,2,2);
glutSwapBuffers();
}
void keyboard(unsigned char key, int x, int y) {
}
void mouse(int button, int state, int x, int y) {
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutInitWindowSize(600, 400);
glutKeyboardFunc(keyboard);
glutMouseFunc(mouse);
glutCreateWindow("Simple");
glutDisplayFunc(display);
glInit();
glutMainLoop();
return 0;
}