Jump to content
  • Advertisement
Sign in to follow this  
BlackWind

display list and multitexturing

This topic is 3686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Advertisement
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
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
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
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
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
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!