Ok, so there you are using :
- TEXTURE0 as a color texture (some kind of blue texture for Earth, red texture for Mars, grey texture for moon... or even your own planet)
- TEXTURE1 as detail texture (greyscale image that adds little wrinklets and stuff like)
- TEXTURE2 as a shadow map (greyscale image that shades the planet because OpenGL lighting isn''t enough for your case)
In the multitexture pipeline, you would like to have :
incoming color = color from glColor or from OpenGL lighting equations
output of texture unit 0 = texture color from texture lookup 0 (planet color), probably modulated by the incoming color
output of texture unit 1 = multiply previous texture result (planet color) by texture color from texture lookup 1 (detail map), and scaled by two
output of texture unit 2 = modulate previous texture result (planet color with detail) by texture color from texture lookup 2 (shadowmap)
First of all, you may check how many texture units are supported by your graphics card.
Call glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &nb_texture_units);
Your card supports at most 2 texture units in hardware. Though, maybe you can use a third texture unit if the driver allow so.
Secondly, you may set up texture environments for all your texture units. That''s the best way to achieve the desired result without side-effects.
//build the detailmapped surfaceglActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_2D);glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE /*or GL_MODULATE*/); // NEWBind(pTexID); //glBindTexture()glActiveTextureARB(GL_TEXTURE1_ARB);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); // NEWglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE); // NEWglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR); // NEWglTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS); // NEWglTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR); // NEWglTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);Bind(pDetailTexID);glMatrixMode(GL_TEXTURE);glLoadIdentity();glScalef(pDetailLevel, pDetailLevel, 1);glMatrixMode(GL_MODELVIEW);//add the final textureglClientActiveTextureARB(GL_TEXTURE2_ARB);glEnable(GL_TEXTURE_2D);glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // NEWBind(ShadowMapID);
Thirdly, you use vertex arrays but I don''t get how you define texture coordinates arrays.
Do you use a different texture coordinate array for every texture unit, or would you like to "share" the texture coordinate array for all units ?
I mean, when/where do you call glTexCoordPointer ? Do you call it for each texture unit ? Do you call it once only ?
Finally, when you write :
quote:
However, switching the glActiveTextureARB() to glClientActiveTextureARB() will give me a neat white surface...
you probably mean that calling glClientActiveTextureARB does NOT give you the desired effect, but calling glActiveTextureARB does give it to you. Is that right ?
Also, what texture unit are you talking about ? TEXTURE2 as shown in your sample code ?