Hi,
I try now for hours to understand why my screen is still black. I use qt to draw a simple quad. At first I tried a polygon in 2d. That worked. Here is the code
void GLtest::initializeGL()
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_MULTISAMPLE);
static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
}
//! [6]
//! [7]
void GLtest::paintGL()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLenum errorcode;
errorcode = glGetError();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1,0,0);
errorcode = glGetError();
glBegin(GL_QUADS);
glVertex3f(400,400,-8);
glVertex3f(400,-400,8);
glVertex3f(-400,-400,-8);
glVertex3f(-400,400,8);
glEnd();
errorcode = glGetError();
}
//! [7]
//! [8]
void GLtest::resizeGL(int width, int height)
{
int side = qMin(width, height);
glViewport((width - side) / 2, (height - side) / 2, side, side);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
#ifdef QT_OPENGL_ES_1
glOrthof(-0.5, +0.5, -0.5, +0.5, 4.0, 150.0);
#else
glOrtho(-0.5, +0.5, -0.5, +0.5, 4.0, 150.0);
#endif
glMatrixMode(GL_MODELVIEW);
}
It is a Problem I get often playing with opengl.Is there a short shecklist, what to do if the screen keeps beeing black? What is the minimal code to get this quad drawn in my window?
Thanks for help