Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Does glTexEnvf not work accross several glDrawElements passes?

  1. #1
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Does glTexEnvf not work accross several glDrawElements passes?

    I guess the best way to explain it would be like this. Say my video card only supports up to 2 texture units for multitexturing(exageration for simplicity), now say that my model had 4 texture layers. All 4 textures need to be combined together to make some sort of cool looking texture, but since it seems that glTexEnvf only works with the current texture units 1 and 2, I need to call glDrawElements again for the second two texture units. Only problem is, is that it doesn't work. What happens is that the second call to glDrawElements overwrites the previous two textures draw.

    Am I suppose to use a glBlendFunc in this situation?

    I want to deal with texture layers like this so that my algorithm won't even stutter if it detects differant max multitexture unit amounts.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Aug 2000
    Location
    Portsmouth, Hampshire, England
    Posts
    1,063

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    Dude, thats multipass. Using two render calls on the same geometry, with differing render states is multipass, and the only way to combine the results of multiple passes is using blending.

    Dont mean to offend, but I was under the impresion that you were quite advanced in OpenGL, and am surprised you're asking this.

    Nutty

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    No offense taken. I am still quite weak in a few places in OpenGL. To name them: Vertex Programs, Stencil Tests, glBlendFunc and MultiTexturing.

    Other than that, I'm good to go .

    So a multipass is when you have to actually call glDrawElements again to blend over the same geomentry, correct? This is where glBlendFunc scares me . Is it possible to carry accross the same blending mode from glTexEnv over to glBlendFunc?

    I sound like a newb

    If I had more time to experiment with this stuff, I'd know it by now. Once Spider3D has a solid foundation(it does now because I can export model directly from LightWave), then I can impliment all the stuff I don't know using Spider3D.

    Also, I usually go looking for info before coming to places like this, so it may seem like I know more than I do simply because I only answer question I'm pretty sure I know the answers too...and that's far and few between

    [This message has been edited by WhatEver (edited 06-07-2002).]

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    Oh, you can add glTexEnv to that list of things I don't know well .

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Aug 2000
    Location
    Portsmouth, Hampshire, England
    Posts
    1,063

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    So a multipass is when you have to actually call glDrawElements again to blend over the same geomentry, correct?
    Yep.

    This is where glBlendFunc scares me
    It's not that bad once you know the equation. The equation is.

    (Src * SF) + (Dest * DF)

    Where Src is the computed fragments of the current pass. i.e. the result of the multi-texturing, the value computed at the end of Register combiners, the value that is written into the framebuffer under non blend.

    Dest is the color in the framebuffer.

    SF and DF are source and destination blend factors. These are the GL_ONE, GL_ZERO, GL_SRC_ALPHA, etc etc.. things.

    Theres also a blend equation extension, that allows you to use subtractive blending, and reverse the order of subtraction also.

    You dont have the as much flexability with blending, as you do with RC's or even TexEnv, which can make converting heavily textured geometry difficult to split into multipass, if they all use quite complex Texture combinations. Usually they dont tho.

    Nutty

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    Ok, now that makes more sense.

    Thx Nutty!

  7. #7
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    I've been trying to figure this out for 4 hours now. I have my DOT3 bumpmapping working in another program of mine, but I can't get it going in a new program.

    Here's what it looks like:

    s3dClientActiveTextureARB(GL_TEXTURE0_ARB);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Bumpmap);

    glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
    glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, 0x8740);
    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT);
    glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
    glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
    glTexEnvf(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

    glTexCoordPointer(2, GL_FLOAT, 0, UVMaps[SurfaceCur->Layers[0].UVMapIndex].UVs);

    s3dClientActiveTextureARB(GL_TEXTURE1_ARB);
    glEnable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, Texture);

    glTexCoordPointer(2, GL_FLOAT, 0, UVMaps[SurfaceCur->Layers[0].UVMapIndex].UVs);

    This code is suppose to blend GL_TEXTURE1_ARB on top of GL_TEXTURE0_ARB. If I only use GL_TEXTURE0_ARB, then I get a bumpmapped surface that is black and white only.

    Any suggestion why GL_TEXTURE1_ARB isn't blending properly?

  8. #8
    Senior Member OpenGL Pro
    Join Date
    Aug 2000
    Location
    Portsmouth, Hampshire, England
    Posts
    1,063

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, 0x8740);
    What the hell is 0x8740?? I can't find that in gl.h or texture env combine tokens?

    Change that to the correct token definition you are wanting, and see if it helps.

    Nutty

  9. #9
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    3,115

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    What the hell is 0x8740?? I can't find that in gl.h or texture env combine tokens?
    Taken from latest glext.h
    Code :
    #ifndef GL_EXT_texture_env_dot3
    #define GL_DOT3_RGB_EXT                   0x8740
    #define GL_DOT3_RGBA_EXT                  0x8741
    #endif

  10. #10
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    550

    Re: Does glTexEnvf not work accross several glDrawElements passes?

    I couldn't find the latest glext.h also, so I just used the hex value I got from NitroGLs code because I was avoiding defining the constant myself. Lazynes on my part.

    Anyway, anyone know why the second texture unit won't blend properly?

    I post some screenies in a sec.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •