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?