It took me >1 day and I still haven't figured out why. I'm using Ubuntu 9.10, trying to make a simple OpenGL to work in c++.
whenever I used GLUT_SINGLE parameter, it gives me a full black screen. I had to click mouse randomly on that screen in order to get out. This is so much annoying. Possibly a bug. Can anybody help?
Here is the code that I use, drawing a simple triangle in c++:
#include <GL/glut.h>
#include <GL/gl.h>
#include <GL/glu.h>
void myDisplay()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex3f(-0.5,-0.5,0.0);
glVertex3f(0.5,0.0,0.0);
glVertex3f(0.0,0.5,0.0);
glEnd();
glFlush();
glutSwapBuffers();
}
void myReshape(int a, int b)
{
}
void myMouse(int a, int b, int c, int d)
{
}
void myKeyboard(unsigned char c, int a, int b)
{
}
void myInit()
{
}
int main(int argc, char ** argv)
{
glutInit(&argc,argv); // initiaize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set the display mode
glutInitWindowSize(640,480); // set window size
glutInitWindowPosition(0,0);
glutCreateWindow("first window");
glutDisplayFunc(myDisplay);
glutReshapeFunc(myReshape);
//glutMouseFunc(myMouse);
//glutKeyboardFunc(myKeyboard);
myInit();
glutMainLoop();
return 0;
}