Hi,
I've created a OpenGL widget class and I create two objects of this class.
I'm using this code to show the images captured from two cameras. When a image is captured, it is sended to the main thread that have the two openGL widgets and tell them to show the image.
"initializeGL" function
Code:
glClearColor(0.0f,0.0f,0.0f,1.0f); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glFlush();
"showImage": Function that show the image
Code:
glClear(GL_COLOR_BUFFER_BIT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ALIGNMENT,1); glPixelStorei(GL_UNPACK_ROW_LENGTH,0); glPixelStorei(GL_UNPACK_SKIP_ROWS,0); glPixelStorei(GL_UNPACK_SKIP_PIXELS,0); glTexImage2D(GL_TEXTURE_2D,0,1,iWidth,iHeight,0,GL_LUMINANCE,GL_UNSIGNED_BYTE,pcData); glBegin(GL_QUADS); glTexCoord2f(0.0f, 1.0f); glVertex2f(0.0f, 0.0f); glTexCoord2f(1.0f, 1.0f); glVertex2f(float(width()), 0.0f); glTexCoord2f(1.0f, 0.0f); glVertex2f(float(width()), float(height())); glTexCoord2f(0.0f, 0.0f); glVertex2f(0.0f, float(height())); glEnd(); glFlush(); updateGL();
The problem is that sometimes the image from camera1 is shown on widget2 and sometimes the image from the camera2 is shown on the widget1. Note that stopping one camera, the other one is displaying at its widget without problem, so I think that I have a OpenGL problem.
Thanks,