Sign in to follow this  
clapton

GL_ARB_multitexture

Recommended Posts

clapton    234
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);
        
        glBegin(GL_QUADS);
            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);
        glBegin(GL_QUADS);
            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();
Thanks in advance! :)

Share this post


Link to post
Share on other sites
mikeman    2942
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 this post


Link to post
Share on other sites
clapton    234
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 this post


Link to post
Share on other sites
James Trotter    432
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 this post


Link to post
Share on other sites
clapton    234
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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this