GLUT_SINGLE显示黑屏 [英] GLUT_SINGLE displays a black screen
问题描述
这花了我> 1天,我还没有弄清楚为什么。
我使用Ubuntu 9.10,试图使一个简单的OpenGL在c ++中工作。
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++.
每当我使用GLUT_SINGLE参数时,它会给我一个完整的黑屏。我不得不点击鼠标随机在屏幕上,为了出去。这太烦人了。可能是一个错误。
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?
这里是我使用的代码,在c ++中绘制一个简单的三角形:
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;
}
推荐答案
9.10,最新更新。用
I'm also using Ubuntu 9.10, with the latest updates. When compiling your code with
g++ -o test -lglut -lGLU -lGL test.cpp
它工作完美。这可能是一个错误。
it works perfectly. This could indeed be a bug.
其他OpenGL应用程序使用单缓冲吗?您尝试了其他视频驱动程序(非免费vs.免费)吗?
Do other OpenGL applications work with single buffering? Did you try a different video driver (non-free vs. free)?
这篇关于GLUT_SINGLE显示黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!