Results 1 to 8 of 8

Thread: Multi-Texture and Vertex Array Problems

  1. #1
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Multi-Texture and Vertex Array Problems

    When attempting to multi-texture with vertex arrays, the 2nd and 3rd textures (units 1 and 2) do not show up at all on my model. The textures are loaded correctly.

    In some instances the program runs slower (indicating multi-textureing) however only the base texture (Unit 0) appears.

    I am using an ATi Rage Fury Pro and I checked other posts but they did not solve my problem.

    Sample code:
    // NOTE: Texture unit 1 has already been enabled.
    glClientActiveTextureARB( GL_TEXTURE1_ARB); // Select unit 1
    //glActiveTextureARB( GL_TEXTURE1_ARB); // glClient... should be used intsead
    glEnableClientState( GL_TEXTURE_COORD_ARRAY); // Use this texture for VertArray
    glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2); // Use these tex coords
    glBindTexture( GL_TEXTURE_2D, texUnit2_id); // Use this texture for tex unit 1
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // Is this needed and why

    Thanks for the help

  2. #2
    Member Contributor
    Join Date
    Mar 2002
    Posts
    61

    Re: Multi-Texture and Vertex Array Problems

    As far as i understand, is see that you're talking about three texture units when Rage Fury only supports two. You may confusing texture units and texture objects.
    "Units" stands for the hardware registers which holds the texture to later mix them "hardwarely", whereas texture object stands for the "OpenGL name" of the texture when you call glBindTexture().

    To answer your question you'll to show more of you display/render function.

  3. #3
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Multi-Texture and Vertex Array Problems

    Here is a snipit of the rendering function

    // Executed before main program loop
    .
    .
    .
    glActiveTextureARB( GL_TEXTURE1_ARB);
    glEnable( GL_TEXTURE_2D); // Enable second texture unit

    glActiveTextureARB( GL_TEXTURE2_ARB);
    glEnable( GL_TEXTURE_2D); // Enable third texture unit

    glActiveTextureARB( GL_TEXTURE0_ARB); // Active Texture 0 enabled previously
    .
    .
    do
    renderArray();
    loop
    .
    .
    .

    // This is what my Vertex Array rendering function does each time it is called.
    // The class "skArrays" stores the model verts and array indices.
    void renderArray( void)
    {

    glEnableClientState( GL_VERTEX_ARRAY);
    glVertexPointer( 4, GL_FLOAT, 0, skArrays.rendVerts); // Renderable Verticies

    glEnableClientState( GL_NORMAL_ARRAY);
    glNormalPointer( GL_FLOAT, 0, skArrays.norm);

    // Extra Texture
    glClientActiveTextureARB( GL_TEXTURE1_ARB);
    glEnableClientState( GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2);
    glBindTexture( GL_TEXTURE_2D, texUnit2_id);
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

    // Base (Default) Texture
    glClientActiveTextureARB( GL_TEXTURE0_ARB);
    glEnableClientState( GL_TEXTURE_COORD_ARRAY);
    glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex);
    glBindTexture( GL_TEXTURE_2D, baseTex_id);

    if( glLockArrays) glLockArrays( 0, num_Verts_To_Lock); // Compiled Vertex Array Enabled

    glDrawElements( GL_TRIANGLES, triCount*3, GL_UNSIGNED_SHORT, skArrays.indexArray);

    if( glUnlockArrays) glUnlockArrays(); // Compiled Vertex Array Disabled

    glClientActiveTextureARB( GL_TEXTURE1_ARB);
    glDisableClientState( GL_TEXTURE_COORD_ARRAY);

    glClientActiveTextureARB( GL_TEXTURE0_ARB);
    glDisableClientState( GL_TEXTURE_COORD_ARRAY);

    glDisableClientState( GL_NORMAL_ARRAY);
    glDisableClientState( GL_VERTEX_ARRAY);

    } // Function ends

  4. #4
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Multi-Texture and Vertex Array Problems

    I am just bumping this topic back up.

  5. #5
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Multi-Texture and Vertex Array Problems

    Does anyone know where I can find official and very detailed documentation on multi-texturing and vertex arrays for OpenGL because all the sites I have found and checked are not helping me solve my problem. And I don't want to have to spend days doing trial and error to fix it.

    Thanks for the help.

  6. #6
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Multi-Texture and Vertex Array Problems

    I finally got it to work (by luck), however I had to use this:

    glActiveTextureARB( GL_TEXTURE1_ARB);
    glClientActiveTextureARB( GL_TEXTURE1_ARB);

    I had to use BOTH functions at the same time however this was never stated in any of the documentation that I read. Using either one alone caused multi-texturing to not function at all.

    Why do I have to use both of these functions when it seems like only glClientActiveTextureARB() should be used when working with vertex arrays?

  7. #7
    Senior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    410

    Re: Multi-Texture and Vertex Array Problems

    I found out recently that glClientActiveTextureARB sets which TEX_COORD_ARRAY is going to be set. Each texture unit can use seperate texture coordinates.

    So here ya go:

    glEnableClientState( GL_TEXTURE_COORD_ARRAY);

    glActiveTextureARB( GL_TEXTURE1_ARB);
    glBindTexture( GL_TEXTURE_2D, texUnit2_id);

    glClientActiveTextureARB( GL_TEXTURE1_ARB);
    glTexCoordPointer( 2, GL_FLOAT, 0, skArrays.tex2);

    //modulate is src_texel * dst_texel = output fragment
    glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  8. #8
    Member Contributor
    Join Date
    Jun 2002
    Posts
    68

    Re: Multi-Texture and Vertex Array Problems

    I understand now, thanks!!

Similar Threads

  1. vao invalid use - problems with vertex array
    By chromosom in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 06-01-2014, 06:27 PM
  2. Vertex array problems
    By Nychold in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-06-2004, 06:55 PM
  3. Vertex array problems
    By in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-04-2003, 09:25 AM
  4. Vertex Array problems
    By Halcyon in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-11-2003, 10:37 AM
  5. Using multi-texture, vertex array, and compression
    By HFAFiend in forum OpenGL: Advanced Coding
    Replies: 12
    Last Post: 03-23-2001, 03:05 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