OpenGL texture disappearing when window is resized
Posted: Wed Sep 14, 2011 12:35 am
I have a small tile rendered on the top left corner of my window and whenever I try to make the window longer vertically, the texture starts to disappear. This only occurs when I stretch the screen vertically and stretching the screen horizontally works fine. I used the search feature here in the forums and others have had similar problems but none where the texture was disappearing. Btw this is in Qt with rendering in OGL. How can I keep the texture from disappearing when I resize the window vertically?
Here is my resize window function:
And my rendering function is as follows:
Here is my resize window function:
Code: Select all
void GLWidget::resizeGL(int width, int height) {
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glViewport( 0, 0, width, height );
glOrtho( 0.0, width, height, 0.0, -1.0, 1.0 );
//Initialize modelview matrix
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
}
Code: Select all
void GLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
glBindTexture( GL_TEXTURE_2D, imageID );
glBegin( GL_QUADS );
glTexCoord2f( 0.0, 1.0 ); glVertex3f( 0.0, 0.0, 0.0 );
glTexCoord2f( 32.0 / 128.0, 1.0 ); glVertex3f( 32.0, 0.0, 0.0 );
glTexCoord2f( 0.0, 32.0 / 64.0 ); glVertex3f( 32.0, 32.0, 0.0 );
glTexCoord2f( 32.0 / 128.0, 32.0 / 64.0 ); glVertex3f( 0.0, 32.0, 0.0 );
glEnd();
}