Sign in to follow this  
BlackWind

display list and multitexturing

Recommended Posts

BlackWind    212
Hi, i'm drawing a map with an octree. I already have the display list implemented. But when i try to combine it with multitexturing....well, it happens nothing hehe. here is the code:

// the detail for the terrain
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[DETAIL_ID]);

// the for that goes trough all the nodes and vertices of the octree subdivied //world
for( ... ... ...)
{
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, myWorld.m_Textures[textureID]);

if( pTexVerts )
{
  // i think here might be the problem
  glClientActiveTextureARB(GL_TEXTURE0_ARB);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);
  glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);	

  glClientActiveTextureARB(GL_TEXTURE1_ARB);
  glEnableClientState(GL_TEXTURE_COORD_ARRAY);				
  glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);
}

// some code for the verts and the normals
.........

glDrawElements(....);
}






if i remove the glActiveTextureARB and the glClienteActiveTextureARB, and leave only 1 texture, it works fine. The problem is with the multitexturing. p.s.: i know that wiht vbos may be cooler. But i want to stick with displays lists because i got it already "working" and i'm in kind of a hurry. thanks a lot for your time!

Share this post


Link to post
Share on other sites
V-man    813
I don't see any reason why it wouldn`t work.
Maybe call glTexEnvi(.., ..., GL_MODULATE) for each texture unit.


// the detail for the terrain
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[DETAIL_ID]);
glTexEnvi(.., ..., GL_MODULATE)

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, myWorld.m_Textures[textureID]);
glTexEnvi(.., ..., GL_MODULATE)



I would recommend using shaders at this point in time.
glTexEnvi and the texture combiners feature is too old. Time to move to shaders.

Share this post


Link to post
Share on other sites
MARS_999    1627
Why are you sending the same exact texture coordinates to two different pointers?

glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);
glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);

and you do know that you are sending in two floats per texture coordinate.

float pTexVerts[width*height*2];

Share this post


Link to post
Share on other sites
BlackWind    212
Quote:
Original post by MARS_999
Why are you sending the same exact texture coordinates to two different pointers?

glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);
glTexCoordPointer(2, GL_FLOAT, 0, pTexVerts);


Because the second texture its only the detail texture to map over the first one in the same coordinates.

For example, BEFORE i had the display lists, i did the multitexruting this way:
(the same code for init that is above), and then for rendering:


glMultiTexCoord2fARB(GL_TEXTURE0_ARB, pTexVerts[textIndex].x, pTexVerts[textIndex].y);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, pTexVerts[textIndex].x, pTexVerts[textIndex].y);




and it worked perfectly.
Now with the display lists is the problem with multitexturing (with one texture there is no problem)


Quote:
Original post by MARS_999
and you do know that you are sending in two floats per texture coordinate.

float pTexVerts[width*height*2];


i dont understand the question.
Do i have to change the number of floats to send? why?

thanks...

Share this post


Link to post
Share on other sites
MARS_999    1627
Do i have to change the number of floats to send? why?

You are telling OPenGL you want to send 2 floats per vertex. So I posted

float pTexVerts[width*height*2]; to make sure you are sending two floats per vertex and not 3 or 4.

Share this post


Link to post
Share on other sites
BlackWind    212
Quote:
Original post by MARS_999
Do i have to change the number of floats to send? why?

You are telling OPenGL you want to send 2 floats per vertex. So I posted

float pTexVerts[width*height*2]; to make sure you are sending two floats per vertex and not 3 or 4.


yep! i'm sending 2 floats per vertex.
any other ideas for my prob?

cheers!

Share this post


Link to post
Share on other sites
BlackWind    212
based on that code, an other tutorials it seems to be that my code is ok.
im going to keep checking all the code to see if the error is in other part....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this