Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

glCopyTexSubImage2D fails

This topic is 2482 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

This is the first time I've come across this problem. In my latest game, the function known as glCopyTexSubImage2D constantly fails. When I check glGetError, it returns GL_INVALID_ENUM. I have absolutely no idea why either. It doesn't matter what I do, it always does this. I'll post my code so I can explain it to you.



//--------------------------------------------------------------------------------------
// 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.

Share this post


Link to post
Share on other sites
Advertisement
glTexImage2D( GL_tex_rect, 1, pixel_format, width, height, 0, pixel_format, GL_UNSIGNED_BYTE, NULL );


Why is your level parameter equal to 1?

Share this post


Link to post
Share on other sites

Also, read what the function parameters are. Your first parameter is not even valid.
http://www.opengl.or...xSubImage2D.xml

Both GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB are valid parameters, so I don't see anything wrong with that. Although the latter is only valid if either the rectangle texture extension or sufficiently high OpenGL version is available.

Share this post


Link to post
Share on other sites
Hidden

Both GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB are valid parameters, so I don't see anything wrong with that. Although the latter is only valid if either the rectangle texture extension or sufficiently high OpenGL version is available.

Yes, GL_TEXTURE_RECTANGLE_ARB is valid, but [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

GL_tex_rect? What is that?[/font]

Share this post


Link to post

glTexImage2D( GL_tex_rect, 1, pixel_format, width, height, 0, pixel_format, GL_UNSIGNED_BYTE, NULL );


Why is your level parameter equal to 1?

Ah, that's the problem. I stupidly got the mip-level parameter confused with that of Direct3D's D3DXCreateTexture! I can't believe that it was the problem the whole time! Thanks.


[quote name='dpadam450' timestamp='1329925027' post='4915523']
Also, read what the function parameters are. Your first parameter is not even valid.
http://www.opengl.or...xSubImage2D.xml

Both GL_TEXTURE_2D and GL_TEXTURE_RECTANGLE_ARB are valid parameters, so I don't see anything wrong with that. Although the latter is only valid if either the rectangle texture extension or sufficiently high OpenGL version is available.
[/quote]
Well, I did forget to mention that my OpenGL implementation does support GL_TEXTURE_RECTANGLE_ARB and NV.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!