Il m'a fallu> 1 jour et je n'ai toujours pas compris pourquoi. J'utilise Ubuntu 9.10, en essayant de faire un simple OpenGL pour travailler en C++.GLUT_SINGLE affiche un écran noir
Chaque fois que j'ai utilisé le paramètre GLUT_SINGLE, cela me donne un écran noir complet. J'ai dû cliquer sur la souris au hasard sur cet écran pour sortir. C'est tellement énervant. Peut-être un bug. Quelqu'un peut-il aider?
Voici le code que j'utilise, dessiner un triangle simple 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;
}
Il ne devrait pas être nécessaire d'appeler 'glSwapBuffers()' dans une fenêtre à tampon unique. Cela ne devrait cependant pas avoir d'effet. – Thomas
Fonctionne bien pour moi sur Win7 x64. –