Archived

This topic is now archived and is closed to further replies.

VanKurt

Multitexturing: Unit2 is ON although it's OFF

Recommended Posts

ARGH! I''m trying to do a simple multitexturing test but it doesn''t work as I want it to! I set up my two color arrays this way:
  
// SETUP COLOR ARRAYS

color1[ctr][0] = 1;	// RED

color1[ctr][1] = 0;
color1[ctr][2] = 0;

color2[ctr][0] = 0;	// GREEN

color2[ctr][1] = 1;
color2[ctr][2] = 0;
  
Then I enable two texture-units:
  
// THE VERTEX ARRAY

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, 0, terrain);

// TEXTURE UNIT 1

glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, 0, texcoords );
glColorPointer( 4, GL_FLOAT, 0, color1 );	// COLOR1


// TEXTURE UNIT 2

glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer( 2, GL_FLOAT, 0, texcoords );
glColorPointer( 4, GL_FLOAT, 0, color2 );	// COLOR2



// TexUnit1 shut up

glActiveTextureARB( GL_TEXTURE1_ARB );
glDisable( GL_TEXTURE_2D);
  
Then I draw my object, using texture-unit 0 ONLY !!!
  
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D);
myTexMan.Bind(tex1);

for (int z = 0; z < 5-1; z++)
{
	glDrawElements(GL_TRIANGLE_STRIP, 10, GL_UNSIGNED_INT, &indices[z * 5 * 2]);
}// end for

  
What I expect? That the texture is RED because I set color1 to 1,0,0 and TextureUnit0 uses only this array. But the image is GREEN!!! Why? I didn''t use the second textureunit so it shouldn''t affect anything.... Thanks, vK

Share this post


Link to post
Share on other sites
I might be wrong, but isn''t there only one colorpointer in openGL i.e. it is not specific to a texture unit, but is a global setting, so you are setting it to the color2 array, rather than color1

Share this post


Link to post
Share on other sites
There is only one colorpointer? That would explain everything!

But how can I texture my terain then?

What I wanted to do is to use 6-TextureUnits, each having its own colorpointer (only alpha component is important), so that I can decide whre what type of ground should be dominant by setting the color(alpha) values....

Share this post


Link to post
Share on other sites
You have 2 color pointers (primary & secundary). That''s 7 weights (secundary only has RGB part). Just use all of the color chanesl for weights.

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites
You can use dot product in register combiner or fragment shader to extract intividual color components.

(R,G,B) DOT ( 0, 0, 1 ) = B

Get it?

And I forgot one thing. You actualy got 8 weights. You have 7 in color chanes and calculate 8 by w8 = 1 - w7-w6-w5...

You should never let your fears become the boundaries of your dreams.

Share this post


Link to post
Share on other sites