Jump to content
  • Advertisement
Sign in to follow this  
evl_one

OpenGL MultiTexture problem!!!!!

This topic is 4843 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 folk, my current 3d OpenGL project is to simulate the solar system. First i try to make the earth. Its contains 2 texture. the first is the planet overview and the second is the cloud texture. I have read alot of post about the multitexture but it wont help alot. :( When i switch to the intermidiat mode i get the right result. because it to slow i use "glInterleavedArrays" to speed it up. My problem is when i try to use "glInterleavedArrays" my second texture is solid and i cant see the texture under it. i hope you guys can help me with this problem. (sorry about my bad english) thanks in advance SOURCE CODE: glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glActiveTextureARB(GL_TEXTURE0_ARB); glClientActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, terrainTex.ID); glActiveTextureARB(GL_TEXTURE1_ARB); glClientActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, terrainDetailTex.ID); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB); glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2); // interleave glInterleavedArrays(GL_T2F_N3F_V3F,0,(*iObjectCounter)->getMeshData() ); // draw object glDrawArrays(GL_TRIANGLES, 0,(*iObjectCounter)->getTotalFaces()*3); glActiveTextureARB(GL_TEXTURE1_ARB); glDisable(GL_TEXTURE_2D); glClientActiveTextureARB(GL_TEXTURE1_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); glClientActiveTextureARB(GL_TEXTURE0_ARB); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_VERTEX_ARRAY);

Share this post


Link to post
Share on other sites
Advertisement
Without use GL_COMBINER try this simple solution

#texture unit 0
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE, GL_MODULATE);

and (global)

Enable(GL_BLEND)
BlendFunc(GL_SRC_ALPHA, GL_ZERO)

I use this simple blending with the texture1 RGB and texture2 RGB/ALPHA (use RGB for your clouds)

Share this post


Link to post
Share on other sites
I don't see you enabling texture_coord_arrays anywhere in there. You will need to enable it for both texture units and send a glTexCoordPointer for each unit as well. Also, don't bother using glInterleavedArrays, it doesn't have enough supported formats. You can still use arrays that are interleaved with data with the gl*Pointer functions. So you can do something like this (probably some errors in there, I can't test it right now)...

struct Vertex
{
Vec3 vertex;
Vec3 normal;
Vec2 uv0;
Vec2 uv1;
};
. . .
Here, vertices is an array of the above Vertex struct.

glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(Vertex), &vertices[0].normal);

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex0);
glClientActiveTextureARB(GL_TEXTURE0_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &vertices[0].uv0);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tex1);
glClientActiveTextureARB(GL_TEXTURE1_ARB);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), &vertices[0].uv1);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(Vertex), &vertices[0].vertex);

glDrawArrays(GL_TRIANGLES, 0, numVertices*3);

Note that I bind the vertex array (glVertexPointer) last. This is because nvidia cards seem to do all the heavy work on vertex arrays on the glVertexPointer call, whereas ATI seems to do it when they're used (I'm assuming that's where ATI does it anyway, I haven't read anything official from them about it, but NVidia does recommend calling glVertexPointer last).

Anyway, I hope all that was at least a little helpful (and relevant).

Share this post


Link to post
Share on other sites
thx guys,

I will try the blend and the GL_MODULATE option for the glTexEnvi.

kalidor :
i try to convert it back to vertex array.


thx for the support!!

Share this post


Link to post
Share on other sites
tHx guys Its working... but i get another problem..

the clouds image(texture1) is show incorrent. The clouds itself is black instead of white.

what do i do wrong??? :S. I follow the example code above but the clouds still black instead of white .

plz help !!..


thx in advace

evl_one

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!