Jump to content
  • Advertisement
Sign in to follow this  
xIshtarx

Multitexturing

This topic is 5003 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

Ive read a few tutorials bout multitexturing but they all used 2 textures. So i tried to just add another 1, but it doesnt work. I just see the first and third texture. And if i disable the first i only see the third.. Is there anything wrong with this code? (Dont think so, cus i copied the main part from a tutorial :) glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)wglGetProcAddress("glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)wglGetProcAddress("glMultiTexCoord2fARB"); CreateTexture(g_Texture, "rood.bmp", 0); CreateTexture(g_Texture, "blauw.bmp", 1); CreateTexture(g_Texture, "geel.bmp", 2); glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, g_Texture[0]); glActiveTextureARB(GL_TEXTURE1_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, g_Texture[1]); glActiveTextureARB(GL_TEXTURE2_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, g_Texture[2]); glPushMatrix(); glTranslatef(-2, 0, 0); glBegin(GL_QUADS); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 1.0f); glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, 1.0f); glVertex3f(-1, 1, 0); glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0f, 0.0f); glMultiTexCoord2fARB(GL_TEXTURE2_ARB, 0.0f, 0.0f); glVertex3f(-1, -1, 0); (and a bit more vertices to make a quare :) Plz help XishtarX

Share this post


Link to post
Share on other sites
Advertisement
Yay i finally found what was wrong,
GL_MAX_TEXTURE_UNITS_ARB seems to be 2. So i cant use 3 textures :). So how do u change that?

Share this post


Link to post
Share on other sites
There's nothing you can do about it,other than buy a new card.You can however use more than 2 textures to render an object,you just need to perform multiple rendering passes and blend the outcome.For example,this modulates 4 textures:


glDepthFunc(GL_LEQUAL);
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[1]);

glActiveTextureARB(GL_TEXTURE2_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, g_Texture[2]);
RenderObject();

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, g_Texture[3]);

glActiveTextureARB(GL_TEXTURE2_ARB);
glBindTexture(GL_TEXTURE_2D, g_Texture[4]);

glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR,GL_ZERO);
RenderObject();
glDisable(GL_BLEND);



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!