Results 1 to 4 of 4

Thread: Problem with multiple glTexCoordPointer() arrays

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2001
    Posts
    16

    Problem with multiple glTexCoordPointer() arrays

    I am seeing a strange problem with glTexCoordPointer() but can't seem to determine what is going on. I think I have some GL wrong but its acting like a compiler problem not addressing the arrays correctly. This is being built on a Linux system.

    I have a cube texture mapped with a textute that spins, just to text mipmapping. The vertexes are in one array of 8 vertexes.

    One versiopn that works correctly has the texture verts in a single array, one per vertex. This produces some interesting patterns but I know why. (one per vertex = not good). The indicies are in a single array, 24 long, to draw the object.

    This all works well.

    NOW...

    Break up the texture verts into six arrays each with an s/t for each vertex.
    Break up the INDICES into six arrays each with 4 values.

    Then instead of one call to glTexCoordPointer & glDrawElements...

    I call the each six times in sucession, (glTexCoordPointer & glDrawElements), to draw the model. The first panel texture is placed OK...All other panels have textures coordinates all messed up.

    I'm sure the data is ok because if I expand to a loop and use (glBegin(),glTexCoord2f(),glVertex3i(),glEnd()) the model draws correctly.

    Anyone seen this???


    BTW...Vertex array is funky incase anyone catches it (int)(id,x,y,z)
    ----CODE SNIPPET FOR ARRAYS----
    void Draw(void)
    {
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glTranslated(Model.location.x, Model.location.y, -Model.location.z);
    glRotated(Model.angle.z, 0.0, 0.0, 1.0);
    glRotated(Model.angle.x, 1.0, 0.0, 0.0);
    glRotated(Model.angle.y, 0.0, 1.0, 0.0);

    glVertexPointer(3, GL_INT, 16, (GLvoid*)((int)g_cube_vertices + sizeof(int)));

    /* Draw model using single call to arrays */
    // glTexCoordPointer(2, GL_SHORT, 0, g_cube_texverts);
    // glDrawElements(GL_QUADS, 24, GL_UNSIGNED_INT, g_cube_indices);

    /* Draw model using multiple calls to arrays */
    glTexCoordPointer(2, GL_SHORT, 0, sidea_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sidea_indices);
    glTexCoordPointer(2, GL_SHORT, 0, sideb_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sideb_indices);
    glTexCoordPointer(2, GL_SHORT, 0, sidec_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sidec_indices);
    glTexCoordPointer(2, GL_SHORT, 0, sided_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sided_indices);
    glTexCoordPointer(2, GL_SHORT, 0, sidee_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sidee_indices);
    glTexCoordPointer(2, GL_SHORT, 0, sidef_txverts);
    glDrawElements(GL_QUADS, 4, GL_UNSIGNED_INT, sidef_indices);

    glFlush();
    glutSwapBuffers();
    }

  2. #2
    Junior Member Newbie
    Join Date
    Aug 2001
    Posts
    16

    Re: Problem with multiple glTexCoordPointer() arrays

    Followup...Could this have anything to do with locking the arrays?

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    2

    Re: Problem with multiple glTexCoordPointer() arrays

    Same issue here, I am struggling with multiple glTexCoordPointer() arrays. Only the initial pointer seems to work. All subsequent calls produce (0,0) coordinate calls. Does anyone know how to fix this?
    /************************************************** **
    INITIALIZATION CODE:
    gl.glEnable(GL10.GL_TEXTURE_2D);
    gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY );
    int txtRef1=loadTexture(.....);
    int txtRef2=loadTexture(.....);
    IntBuffer verBuff=getIntBuffer(.......);
    IntBuffer txtCoord1=getIntBuffer(......);
    IntBuffer txtCoord2=getIntBuffer(.......);
    PER-FRAME CODE:
    gl.glVertexPointer(3, GL10.GL_FIXED, 0, verBuff);
    gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, txtCoord1);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, txtRef1);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, 4);

    gl.glTexCoordPointer(2, GL10.GL_FIXED, 0, txtCoord2);
    gl.glBindTexture(GL10.GL_TEXTURE_2D, txtRef2);
    gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 4, 4);
    ************************************************** ***/
    Any help would be highly appreciated

  4. #4
    Junior Member Newbie
    Join Date
    Sep 2010
    Posts
    2

    Re: Problem with multiple glTexCoordPointer() arrays

    I found my problem. The code above works just fine. The problem was that IntBuffer txtCoord2=getIntBuffer(.......); was not defined correctly. The right way was:

    int one=(int)(1.0f*65536);
    int[] texture = {one,0, one,one, 0,0, 0,one,one,0, one,one, 0,0, 0,one};
    ByteBuffer byteBuf = ByteBuffer.allocateDirect(texture.length * 4);
    byteBuf.order(ByteOrder.nativeOrder());
    IntBuffer txtCoord2 = byteBuf.asIntBuffer();
    txtCoord2.put(data);
    txtCoord2.position(0);

Similar Threads

  1. Multiple texcoord arrays=sure, multiple color streams?
    By mattropolis in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 03-01-2014, 07:52 AM
  2. Multiple Texture Arrays
    By ViolentHamster in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 08-17-2012, 08:05 AM
  3. Big problem show arrays with vertex arrays
    By Rondey in forum OpenGL: Basic Coding
    Replies: 13
    Last Post: 03-15-2009, 10:09 AM
  4. multiple vertex arrays
    By hugo4711 in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 02-02-2004, 10:27 AM
  5. Multiple Vertex Arrays...
    By Richelieu in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-17-2000, 07:10 PM

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