Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Texturing in one pass

  1. #1
    Junior Member Newbie TheFrog's Avatar
    Join Date
    Jul 2009
    Location
    France
    Posts
    2

    Texturing in one pass

    Hi all,

    I have a problem that's really confusing me.

    I'm rendering a cube using array (vertex, color & normals), each side of the cube has a different color.
    this works fine.

    gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, currentObj.objGetTextureArray());
    gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
    gl.glVertexPointer(3, GL.GL_FLOAT ,0, currentObj.objGetVertexArray ());
    gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
    gl.glNormalPointer(GL.GL_FLOAT,0,currentObj.objGet NormalArray ());
    gl.glEnableClientState(GL.GL_COLOR_ARRAY);
    gl.glColorPointer(4, GL.GL_FLOAT ,0,currentObj.objGetColorArray ());


    I want to add a texture to one face of the cube. I use a Texture bind & Texture Array.
    texture.bind();
    gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
    gl.glTexCoordPointer(2, GL.GL_FLOAT, 0, currentObj.objGetTextureArray());

    This works fine, I can see the texture on one side, but all the other faces of the cube have the texture color.
    It is because, I think,the faces with no textures have 0,0 UV coordinates in the array, and OpenGL applies its color.

    The problem is I want to render the cube in one pass.

    If I remove the 0.0 UV coordinates, the array wont match the vertex list.

    Is this possible in one pass ?

    Thanks for your help.

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586

    Re: Texturing in one pass

    If by 'one pass' you mean 1 draw call (glDrawArrays or glDrawElements, etc...) then the answer is no.

    You need to draw the sides that have a texture and then disable texturing and draw the rest of the cube (or vice versa).

  3. #3
    Junior Member Newbie TheFrog's Avatar
    Join Date
    Jul 2009
    Location
    France
    Posts
    2

    Re: Texturing in one pass

    Yes , one pass with glDrawArrays.
    Ok I understand, thanks for your help.

Posting Permissions

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