Results 1 to 8 of 8

Thread: multitexturing

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2001
    Location
    no
    Posts
    10

    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

  2. #2
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    2,833

    Re: multitexturing

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

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

  3. #3
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    469

    Re: multitexturing

    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_RE LACE);// 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_MO DULATE);
    // 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

  4. #4
    Junior Member Newbie
    Join Date
    Nov 2001
    Location
    no
    Posts
    10

    Re: multitexturing

    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

  5. #5
    Senior Member Frequent Contributor
    Join Date
    Oct 2000
    Location
    Belgium
    Posts
    806

    Re: multitexturing

    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

  6. #6
    Junior Member Newbie
    Join Date
    Nov 2001
    Location
    no
    Posts
    10

    Re: multitexturing

    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

  7. #7
    V-man
    Guest

    Re: multitexturing

    Originally posted by TiPiaX:
    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
    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

  8. #8
    Junior Member Newbie
    Join Date
    Nov 2001
    Location
    no
    Posts
    10

    Re: multitexturing

    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

Similar Threads

  1. VBO+multitexturing
    By dletozeun in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-19-2006, 02:20 PM
  2. Multitexturing
    By Jeff_Mills in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-19-2004, 12:56 PM
  3. arb multitexturing
    By divide in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 12-30-2002, 09:15 AM
  4. Multitexturing
    By tobiaso in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-26-2002, 08:39 AM
  5. Multitexturing
    By Fredy in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 02-28-2001, 11:13 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean