Sign in to follow this  

glBindTexture giving GL_INVALID_VALUE

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

Hey guys, I'm doing something wrong, but I really can't figure out what it is.

I create 4 textures during initialization, using this routine:
[code]
void OGLWrapper::CreateTexture(void*, unsigned int Width, unsigned int Height, BYTE *Data, void**, GLuint *TextureOGL)
{
glGenTextures(1, TextureOGL);
CheckError("CreateTexture (glGenTextures)");
glBindTexture(GL_TEXTURE_2D, *TextureOGL);
CheckError("CreateTexture (glBindTexture)");
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, Width, Height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, Data);
CheckError("CreateTexture (glTexImage2D)");
}
[/code]
That routine is called 4 times to create the four textures. The TextureOGL value is stored in the material class (and it turns out to be 1 through 4 for the 4 textures). This runs with no errors reported.

Then I want to use those textures to draw. So I simply try to bind them again with this function, passing in the stored Texture:
[code]
//---------------------------------------------------------------------------
void OGLWrapper::PSSetShaderResource(void*, void*, void*, void*, GLuint TextureOGL)
{
glBindTexture(GL_TEXTURE_2D, TextureOGL);
CheckError("PSSetShaderResource");
}
[/code]
The values coming into this routine are in the range of 1 to 4, so they seem right. But the function is erroring with a GL_INVALID_VALUE. According to the docs, I get this error if "target is not a name returned from a previous call to glGenTextures".

I'm not sure I understand that description, the prototype for that function is
void GlBindTexture(GLenum target, GLuint texture);

Did they mean "texture is not a name returned from.."? Because glGenTextures has nothing to do with the target as far as I can tell.

But either way, the input parameters seem right, so I don't really understand what I'm doing wrong here. Anyone have any ideas? What am I missing?

Share this post


Link to post
Share on other sites
There is an app for that
[url="http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture"]http://www.opengl.or...ating_a_Texture[/url]

Share this post


Link to post
Share on other sites

This topic is 2325 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this