glBindTexture giving GL_INVALID_VALUE

Started by
1 comment, last by RonHiler 12 years, 8 months ago
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?
Creation is an act of sheer will
Advertisement
There is an app for that
http://www.opengl.or...ating_a_Texture
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Cool, thanks V-man, that was the problem (as I'm sure you knew).

I bookmarked that page for future issues :)
Creation is an act of sheer will

This topic is closed to new replies.

Advertisement