• Advertisement
Sign in to follow this  

GL_TEXTURE_RECTANGLE_ARB white screen

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Trying to get GL_TEXTURE_RECTANGLE_ARB working to save memory on older systems I end up always with a white screen. This is the scenario: A black background on which I render a couple of stars looking like white points. Works flawlessly with GL_TEXTURE_2D. Doing the same with GL_TEXTURE_RECTANGLE_ARB and the code snipped below results in white screen.
target = GL_TEXTURE_RECTANGLE_ARB;

// create texture
OGL_CHECK( glGenTextures( 1, &pTexture ) );
OGL_CHECK( glTexImage2D( target, 0, GL_RGBA8, pWidth, pHeight, 0,
	GL_RGBA, GL_UNSIGNED_BYTE, NULL ) );

// bind fbo
OGL_CHECK( pOgl->glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, pFBO ) );

// attach texture as target
OGL_CHECK( pOgl->glActiveTextureARB( GL_TEXTURE0_ARB ) );
OGL_CHECK( glEnable( target ) );
OGL_CHECK( glBindTexture( target, pTexture ) );
OGL_CHECK( glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_WRAP_S, GL_CLAMP ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_WRAP_T, GL_CLAMP ) );

OGL_CHECK( pOgl->glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 
	GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_RECTANGLE_ARB, pTexture, 0 ) );

OGL_CHECK( glBindTexture( target, 0 ) );

// render sky
(...)

// dettach texture from target
OGL_CHECK( pOgl->glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, 
	GL_COLOR_ATTACHMENT0_EXT, target, 0, 0 ) );

// set texture to unit 1
OGL_CHECK( pOgl->glActiveTextureARB( GL_TEXTURE0_ARB ) );
OGL_CHECK( glEnable( target ) );
OGL_CHECK( glBindTexture( target, pTexture ) );
OGL_CHECK( glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_MAG_FILTER, GL_NEAREST ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_MIN_FILTER, GL_NEAREST ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_WRAP_S, GL_CLAMP ) );
OGL_CHECK( glTexParameteri( target, GL_TEXTURE_WRAP_T, GL_CLAMP ) );

// render using GLSL:
/* vertex
uniform sampler2DRect texColor;
void main( void ){
	gl_TexCoord[ 0 ] = gl_MultiTexCoord0;
	gl_Position = vec4( gl_Vertex.xyz, 1.0 );
}
*/
/* fragment
uniform sampler2DRect texColor;
void main( void ){
	gl_FragColor = vec4( texture2DRect( texColor, gl_TexCoord[ 0 ].xy ).rgb, 1.0 );
}
*/

glBegin( GL_QUADS );
	pOgl->glMultiTexCoord2iARB( GL_TEXTURE0_ARB, 0, 0 );
	glVertex2f( -1.0f, -1.0f );
	pOgl->glMultiTexCoord2iARB( GL_TEXTURE0_ARB, pWidth, 0 );
	glVertex2f( 1.0f, -1.0f );
	pOgl->glMultiTexCoord2iARB( GL_TEXTURE0_ARB, pWidth, pHeight );
	glVertex2f( 1.0f, 1.0f );
	pOgl->glMultiTexCoord2iARB( GL_TEXTURE0_ARB, 0, pHeight );
	glVertex2f( -1.0f, 1.0f );
OGL_CHECK( glEnd() );
Any ideas what can be wrong? I googled all day long and adjusted to code to all the tripfalls mentioned there like not using range 0..width or not using GL_LINEAR/GL_NEAREST but no luck.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement