Original Post
Hi people... I am porting these days my 3D engine from Direct3D8 to OpenGL and I''m having some dificulties with multitexturing...
As a test I try to render a quad with two textures "added" together. But it seems that only the second gets draw. the code is as follows:
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, texture1);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, texture2);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_ADD);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
And then i render with glDrawElements() ... what''s wrong? btw the material is set to white, so it''s not that the first texture gets modulated with black or something, after all the output seems like the first texture stage feeds all white pixels to the second stage (as if the texture did not exist and what i see is the material)...
also if i add the two lines
glClientActiveTextureARB(GL_TEXTURE2_ARB);
glDisable(GL_TEXTURE_2D);
which as i understand disables the 3rd texture unit, no texture at all gets rendered (not even the second).
any ideas? am i doing something terribly wrong?
thanx in advance ...
-- Nuclear / the Lab --