alantangcs
12-01-2003, 09:16 PM
Hi all,
Does anyone know if there are any issues when using multitexturing on a pbuffer?
Right now, I have written a tile engine and using register combiners to create a dynamic lightmap for the scene. I think I have set everything up correctly.
wglMakeCurrent( hdc_pbuffer, rc_pbuffer );
// Set up an ortho projection
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glPushMatrix( );
gluOrtho2D( 0, 512, 0, 512 );
// I have disabled stage 1 and got rid of
// the texture combiners already to narrow
// down the problem
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, normalmap );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glActiveTextureARB( GL_TEXTURE1_ARB );
glDisable( GL_TEXTURE_2D );
glDisable( GL_BLEND );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
// Draw the texture to the pbuffer
glColor4f( 1.f, 0.f, 0.f, 1.f );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3i( 0, 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3i( 100, 0, 0 );
glTexCoord2i( 1, 1 );
glVertex3i( 100, 100, 0 );
glTexCoord2i( 0, 1 );
glVertex3i( 0, 100, 0 );
glEnd( );
glPopMatrix( );
//glFlush( ); // Makes no difference if used
wglMakeCurrent( hdc_window, rc_window );
Now what I do to test is to just draw a textured quad of the pbuffer to screen. This works fine so I won't bother posting the code.
However, the actual contents of the pbuffer is not what I expected. First of all, the quad I draw in the code above is not textured (it should be because I enabled texturing on stage 0). It IS colored (it should NOT be because I disabled COLOR_MATERIAL). Everything else works fine. It's just the texturing that has me stumped.
And fyi, the code above definitely works on the screen (i.e., if I comment out 'wglMakeCurrent( hdc_pbuffer, rc_pbuffer )', it will draw directly to the screen - and the texturing works fine like that).
This leads me to suspect that there is an issue with multitexturing on pbuffers. Another possibility is that I need to set up the pbuffer slightly differently to allow for multitexturing.
Does anyone have any ideas?
Thanks,
Alan
Does anyone know if there are any issues when using multitexturing on a pbuffer?
Right now, I have written a tile engine and using register combiners to create a dynamic lightmap for the scene. I think I have set everything up correctly.
wglMakeCurrent( hdc_pbuffer, rc_pbuffer );
// Set up an ortho projection
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glPushMatrix( );
gluOrtho2D( 0, 512, 0, 512 );
// I have disabled stage 1 and got rid of
// the texture combiners already to narrow
// down the problem
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, normalmap );
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
glActiveTextureARB( GL_TEXTURE1_ARB );
glDisable( GL_TEXTURE_2D );
glDisable( GL_BLEND );
glDisable( GL_LIGHTING );
glDisable( GL_COLOR_MATERIAL );
// Draw the texture to the pbuffer
glColor4f( 1.f, 0.f, 0.f, 1.f );
glBegin( GL_QUADS );
glTexCoord2i( 0, 0 );
glVertex3i( 0, 0, 0 );
glTexCoord2i( 1, 0 );
glVertex3i( 100, 0, 0 );
glTexCoord2i( 1, 1 );
glVertex3i( 100, 100, 0 );
glTexCoord2i( 0, 1 );
glVertex3i( 0, 100, 0 );
glEnd( );
glPopMatrix( );
//glFlush( ); // Makes no difference if used
wglMakeCurrent( hdc_window, rc_window );
Now what I do to test is to just draw a textured quad of the pbuffer to screen. This works fine so I won't bother posting the code.
However, the actual contents of the pbuffer is not what I expected. First of all, the quad I draw in the code above is not textured (it should be because I enabled texturing on stage 0). It IS colored (it should NOT be because I disabled COLOR_MATERIAL). Everything else works fine. It's just the texturing that has me stumped.
And fyi, the code above definitely works on the screen (i.e., if I comment out 'wglMakeCurrent( hdc_pbuffer, rc_pbuffer )', it will draw directly to the screen - and the texturing works fine like that).
This leads me to suspect that there is an issue with multitexturing on pbuffers. Another possibility is that I need to set up the pbuffer slightly differently to allow for multitexturing.
Does anyone have any ideas?
Thanks,
Alan