# glBindTexture giving GL_INVALID_VALUE

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

## 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:
 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)"); } 
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:
 //--------------------------------------------------------------------------- void OGLWrapper::PSSetShaderResource(void*, void*, void*, void*, GLuint TextureOGL) { glBindTexture(GL_TEXTURE_2D, TextureOGL); CheckError("PSSetShaderResource"); } 
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 on other sites
Cool, thanks V-man, that was the problem (as I'm sure you knew).

I bookmarked that page for future issues

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002324
×