PDA

View Full Version : update texture problem



chenya
06-03-2008, 06:12 AM
Hi, I am new to OpenGL. I am working on opengl with qt. what I need to do is to display one image. But this image is changing according my application. When I modify the "currentPixmap" out side paintGL(), it looks like my display texture is not updated, until I do window resize whatever to repaint. Here is my code:
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT| GL_DEPTH_BUFFER_BIT);

glBindTexture( GL_TEXTURE_2D, fbObject->bindTexture(currentPixmap));

int i=currentPixmap.width(), j = currentPixmap.height();

GLfloat w = i;
GLfloat h = j;

glEnable(GL_TEXTURE_2D);
glPushMatrix();
glColor3f(1.0, 1.0, 1.0);

glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(0, 0, -5.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(w, 0, -5.0);
glTexCoord2f(1, 1);
glVertex3f(w, h, -5.0);
glTexCoord2f(0.0, 1);
glVertex3f(0, h, -5.0);
glEnd();

glPopMatrix();

glFlush();
}

what can I do to force it to update the texture?

rgpc
06-04-2008, 04:52 AM
Do you actually load the contents of the modified texture into the texture object? Using glTexSubImage2D() for example? The code example you've provided will only USE the image. There's nothing there to actually update it.