display list and multitexturing

Started by
7 comments, last by BlackWind 15 years, 11 months ago
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!
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 terrainglActiveTextureARB(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.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
hi,

i tried your solution and also with combine and nothing.

any ideas?
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];
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...
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.
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!
I don't see any problems.
Try other peoples code

http://developer.download.nvidia.com/SDK/9.5/Samples/3dgraphics_samples.html
http://ati.amd.com/developer/sdk/rage128sdk/MulTex/OGLMulTex.html
http://www.codesampler.com/oglsrc/oglsrc_4.htm
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
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....

This topic is closed to new replies.

Advertisement