//--------------------------------------------------------------------------------------
// Name: create_texture_rectangle
// Desc: Creates a blank texture rectangle
//--------------------------------------------------------------------------------------
GLuint create_texture_rectangle( int width, int height, int bpp )
{
GLuint handle;
GLuint pixel_format = ( bpp == 32 ) ? GL_RGBA : GL_RGB ;
glGenTextures( 1, &handle );
glBindTexture( GL_tex_rect, handle );
glTexImage2D( GL_tex_rect, 1, pixel_format, width, height, 0, pixel_format, GL_UNSIGNED_BYTE, NULL );
glTexParameteri( GL_tex_rect, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_tex_rect, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
return handle;
}
//--------------------------------------------------------------------------------------
// Name: copy_scene_to_texture
// Desc:
//--------------------------------------------------------------------------------------
void copy_scene_to_texture( GLuint *tex, int width, int height )
{
GLenum error;
glEnable( GL_tex_rect );
glBindTexture( GL_tex_rect, *tex );
error = glGetError();
glCopyTexSubImage2D( GL_tex_rect, 0, 0, 0, 0, 0, width, height );
glDisable( GL_tex_rect );
error = glGetError();
if( error != GL_NO_ERROR )
{
// Do whatever...
}
}
Now, this is the code I use to initialize the texture and copy the scene to it. When I set GL_tex_rect to GL_TEXTURE_2D, glBindTexture doesn't fail, but when I use GL_TEXTURE_RECTANGLE_ARB, I get an error for both functions. This usually works for me, but this time, it keeps failing and I don't understand why. This sucks. Any ideas? Thanks.



















