# GL_ARB_multitexture

## Recommended Posts

Hello! After checking a couple of tutorials and descriptions I still haven't found an answer for a question I've got. Consider the following piece of code ... There is a part of scene where I need to use multitexturing to blend the floor with a lightmap :
        glActiveTextureARB(GL_TEXTURE0_ARB);
DevEngine.TextureMgr.BindTexture(TextureTile);
glEnable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
DevEngine.TextureMgr.BindTexture(TextureLightMap);
glEnable(GL_TEXTURE_2D);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -0.35, -0.35);
glVertex3f(-FloorSize, 0.0, -FloorSize);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 8.0, 0.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.35, -0.35);
glVertex3f(FloorSize, 0.0, -FloorSize);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 8.0, 8.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.35, 0.35);
glVertex3f(FloorSize, 0.0, FloorSize);

glMultiTexCoord2fARB(GL_TEXTURE0_ARB, 0.0, 8.0);
glMultiTexCoord2fARB(GL_TEXTURE1_ARB, -0.35, 0.35);
glVertex3f(-FloorSize, 0.0, FloorSize);
glEnd();

glDisable(GL_TEXTURE_2D);   // GL_TEXTURE1_ARB

glActiveTextureARB(GL_TEXTURE0_ARB);

... after it's done, I don't need multitexturing for a rest of scene drawing. The question is - can I use glTexCoord2f() to draw primitives in a 'standard' way or should I use glMulitTexCoord2f(GL_TEXTURE0_ARB, ...) from then on ? To put it another way - after I used glActiveTextureARB once, is it possible to do the following thing :
// (...)
DevEngine.TextureMgr.BindTexture(TextureLight);
glTexCoord2f(1.0, 0.0); glVertex3f((up[0] - right[0]) *  size, (up[1] - right[1]) *  size, (up[2] - right[2]) *  size);
glTexCoord2f(1.0, 1.0); glVertex3f((up[0] + right[0]) *  size, (up[1] + right[1]) *  size, (up[2] + right[2]) *  size);
glTexCoord2f(0.0, 1.0); glVertex3f((right[0] - up[0]) *  size, (right[1] - up[1]) *  size, (right[2] - up[2]) *  size);
glTexCoord2f(0.0, 0.0); glVertex3f((up[0] + right[0]) * -size, (up[1] + right[1]) * -size, (up[2] + right[2]) * -size);
glEnd();


##### Share on other sites
You can use glTexCoord2f() even in your multitexturing code instead of glMultiTexCoord2f(GL_TEXTURE0,...) , all it does is always set the texture coordinates of unit 0. So, when the first parameter of MultiTexCoord is GL_TEXTURE0, glTexCoord() and glMultiTexCoord() are equivalent.

##### Share on other sites
OK, thanks! That's exactly what I wanted to know. :)

Thus, I'll have another question if you don't mind. The problem is that I must have made some mistake when writing a demo because it runs terribly-surprisingly-illogicaly slow on some machines (1-4 fps) while on others it works > 1300 fps. The only part suspected of making the mess is the way I use multitexturing. So ...

    if (bLightmapEnabled)    {         glActiveTextureARB(GL_TEXTURE1_ARB);         glMatrixMode(GL_TEXTURE);            glLoadIdentity();            glTranslatef(0.5, 0.5, 0.0);            glRotatef(-LightRotation, 0.0, 0.0, 1.0);         glMatrixMode(GL_MODELVIEW);                  glActiveTextureARB(GL_TEXTURE0_ARB);         glDisable(GL_TEXTURE_2D);    }

Do you see anything wrong in the code above?

Thanks once again! :)

##### Share on other sites
I don't see anything specifically wrong with that piece of code. However, the code is taken entirely out of context, and it's difficult to tell anything about what might be slowing the application down.
It might have something to do with the machines you're running it on, as well. I can't really do anything but guess, though. Make sure the newest graphics drivers are installed.

Also, you might be wrong about where you think the bottleneck is. The only way to know for certain is to profile the application.

##### Share on other sites
OK, I see. It's possible that the problem lies somewhere else. It might be SDL input as well. Anyway, you can check out the application yourself if you like. :) I'd really appreciate any feedback!

Here you can get it : http://priv.ckp.pl/aero/DemoMD2.exe.

Should you notice some problems, you can try a patch (no lightmap version) : http://priv.ckp.pl/aero/PatchDemoMD2.rar

Thanks :)

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627637
• Total Posts
2978334

• 10
• 12
• 22
• 13
• 33