I wrote and tested some code in Windows XP (Qt 4.7.2) using Visual Studio 2010, and then tried it on another machine with Windows 7 installed.
The program opens QDialog and creates a QGLWidget, where I show webcam images (with some processing). Although images are displayed correctly in Windows XP, at the moment, when I test the program on a Windows 7 machine, QGLWidget turns black and the image does not appear. It is strange, however, that when I move around the window and it leaves the borders of the screen, the image is displayed for a moment and black when I stop moving again, which makes me think that the images are correctly received / processed (several times) and that it may be a problem with QTimer.
Relevant Code:
Initialization:
void GLVideo::initializeGL() { glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
The slot that is called every timeout:
void GLVideo::timeOutSlot() { ReceiveInfo(); LoadTextures(); } void GLVideo::LoadTextures() {
And finally, the widget's drawing function:
void GLVideo::paintGL() { glPushAttrib(GL_ALL_ATTRIB_BITS) ; QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); glPopAttrib() ; glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBindTexture(GL_TEXTURE_2D, texture); glColor4f(1.0f,1.0f,1.0f, 1.0f); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.65f, 1.24f, -3.0f); glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.65f, 1.24f, -3.0f); glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.65f,-1.24f, -3.0f); glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.65f,-1.24f, -3.0f); glEnd(); glDisable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glMatrixMode(GL_MODELVIEW); glPopMatrix();
Any idea what I'm doing wrong? Can QTimer not call SLOT timeOutSlot?