multitexturing

hi,
i want to do lightmaps for a q3 map viewer.
The lightmap is in the file format so i have all what is needed for drawing the lightmap. The problem is that i don’t know how to render a texture on a face that is already textured. Someone said me to use opengl extensions (ARB…) and that’s what i want to do. Thanks for your help

++
TiPiaX

Save yourself the trouble, and just issue this command:-
glDepthFunc(GL_EQUAL);

…and re-render the triangles with the lightmap texture bound.

Hi

using multitexturing isn’t as difficult as its sounds. I suppose you know how to determin if an gl extension is available
When you have succesfully initalized the GL_ARB_multitexture extension(i use nvidia’s opengl SDK’s glh_initextensions; because I am lazy ;-D)

you build your tetxures as usual
// first the base texture
glGenTextures(1,&basetex);
glBindtexture(GL_TEXTURE_2D,basetex);
glTexParameter( with setup for clamping, filtering ) // as usal
glTexImage2D(…)// as usual
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_RELACE);// or GL_MODULATE when you use colors

// second, lightmap texture
glGenTextures(1,&lighttex);
glBindtexture(GL_TEXTURE_2D,lighttex);
glTexParameter( with setup for clamping, filtering ) // as usal
glTexImage2D(…)// as usual
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MODULATE);
// then we have to assign each texture to each texture unit

//texture unit 0
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,basetex);

//texture unit 1
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,lighttex);

// when you render you do following
// because you have 2 textures you have to specify two sets of tex coords

glBegin(GL_QUADS);
glMultiTextureCorrd2fARB(GL_TEXTURE0_ARB,0,0);
glMultiTextureCorrd2fARB(GL_TEXTURE1_ARB,0,0);
glVertex2f(0,0);

glMultiTextureCorrd2fARB(GL_TEXTURE0_ARB,1,0);
glMultiTextureCorrd2fARB(GL_TEXTURE1_ARB,1,0);
glVertex2f(1,0);

glMultiTextureCorrd2fARB(GL_TEXTURE0_ARB,1,1);
glMultiTextureCorrd2fARB(GL_TEXTURE1_ARB,1,1);
glVertex2f(1,1);

glMultiTextureCorrd2fARB(GL_TEXTURE0_ARB,0,1);
glMultiTextureCorrd2fARB(GL_TEXTURE1_ARB,0,1);
glVertex2f(0,1);
glEnd();

you can also use the classical glTexCoord** instead of glMultiTexCoord**(GL_TEXTURE0_ARB) for shortening

to get more information about the extension look at oss.sgi.com, they maintain the extenstions library

bye
ScottManDeath

big thanks for this. But the problem i have is that i am forced to use delphi and i don’t know how to use glmultitexturecoord2f.
I tried to link it with opengl32.dll but i doesn’t work. And i don’t know how to use an api after a getprocaddress in delphi
(delphi sux…)

if you can help me …
TiPiaX

Originally posted by TiPiaX:
big thanks for this. But the problem i have is that i am forced to use delphi and i don’t know how to use glmultitexturecoord2f.

Use wglGetProcAddress() to get the function pointer, then just call it like any other function. http://www.delphi3d.net/listfiles.php?category=3 has several demos written in Delphi that make use of multitexturing (and tons of other extensions, for that matter).

(delphi sux…)

Oh puh-leaze. Remember: “a poor craftsman blames his tools”

  • Tom

hehe you’re right. But it is the first time i have to code with delphi, so there are some things i don’t like

thx

Originally posted by TiPiaX:
[b]hehe you’re right. But it is the first time i have to code with delphi, so there are some things i don’t like

thx[/b]

I think its your first time with functions available in gl 1.2 and up.

wglGetProcAddress is needed on Windows and has nothing to do with Delphi. That’s because opengl32.dll is gl 1.1 still so using wglGetProcAddress will get you functions only available in the ICD.

V-man

hey Vman i know how to do a pointer to a function in c not in pascal.
If you’re not happy that’s your problem