Results 1 to 6 of 6

Thread: GL_QUAD_STRIP + textures

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    GL_QUAD_STRIP + textures

    Hello,
    If I render multiple quads using:
    glBegin(GL_QUAD_STRIP);
    [..]
    glEnd();
    Is it possible to have a different textures on each single quad?
    Or is the only way to have different images on your quads to have one single quad, with different images on it, and then just have like this:
    Code :
    glBindTexture(GL_TEXTURE_2D, texindex);
    glBegin(GL_QUAD_STRIP);
    glTexCoord2f(0.0, 0.0); glVertex3fv(vertices[0]);
    glTexCoord2f(1.0, 0.0); glVertex3fv(vertices[1]);
    glTexCoord2f(0.0, 0.2); glVertex3fv(vertices[2]);
    glTexCoord2f(1.0, 0.2); glVertex3fv(vertices[3]);
    glTexCoord2f(0.0, 0.2); glVertex3fv(vertices[4]);
    glTexCoord2f(1.0, 0.2); glVertex3fv(vertices[5]);
    glTexCoord2f(0.0, 0.5); glVertex3fv(vertices[6]);
    glTexCoord2f(1.0, 0.5); glVertex3fv(vertices[7]);
    [..]
    glEnd();
    Or are there any other ways to do it?

    And how should I imagine 3D textures? Like a cube?
    And is it a good idea to use a 3D texture for water?
    And how can I make 3D textures?
    Thanx in advance,
    Hylke

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: GL_QUAD_STRIP + textures

    Using glBindTexture inside glBegin / glEnd block is not allowed, so you can use only one texture.

    About 3D texture - you can think of it as a space filling a cube or as a set of 2D textures layered one on top of another.
    Do not get confused - 3D texture is something different than cube texture.

    So if you want to use multiple 2D textures inside one glBegin / glEnd block then you can create one 3D texture containing all of the 2D textures and use Z coordinate to select one of these 'layers'.

    float z1 = 0.5f / (float)textureSizeZ;
    float z2 = 1.5f / (float)textureSizeZ;
    float z3 = 2.5f / (float)textureSizeZ;

    glBindTexture(GL_TEXTURE_3D_EXT, texindex);
    glBegin(GL_QUAD_STRIP);
    /* first quad using first layer */
    glTexCoord3DEXT(0.0f, 0.0f, z1); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 0.0f, z1); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 1.0f, z1); glVertex3f(...);
    glTexCoord3DEXT(0.0f, 1.0f, z1); glVertex3f(...);
    /* second quad using third layer */
    glTexCoord3DEXT(0.0f, 0.0f, z3); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 0.0f, z3); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 1.0f, z3); glVertex3f(...);
    glTexCoord3DEXT(0.0f, 1.0f, z3); glVertex3f(...);
    /* third quad mixing layers 2 and 3 */
    glTexCoord3DEXT(0.0f, 0.0f, z2); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 0.0f, z2); glVertex3f(...);
    glTexCoord3DEXT(1.0f, 1.0f, z3); glVertex3f(...);
    glTexCoord3DEXT(0.0f, 1.0f, z3); glVertex3f(...);
    glEnd();

    I'm not using 3D texture for water - 3D texture does not give 3D impression of waves. I simply move some vertices up and down to create waves, and use 2D texture to cover water surface.

    You could use cube texture to simulate reflections on water, but that's a bit more complex topic. Besides, using 2D texture for reflections on water is more commonly used.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: GL_QUAD_STRIP + textures

    or use multitexture

  4. #4
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: GL_QUAD_STRIP + textures

    Ok, thanks for the replies.
    But one final question, how can I create 3D textures? Is there a special format for 3D images(something like gif)? Or do you have to generate it your self using multiple images?
    Thanks in advance,
    Hylke

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,107

    Re: GL_QUAD_STRIP + textures

    how can I create 3D textures?
    It actually depends on what you need this texture for.
    In my example above 3D texture is used to store multiple 2D textures - in this case you just load separate 2D images into it.
    If you need a file format that supports 3D textures then perhaps .dds is what you're looking for (I've never used .dds but I think it supports 3D textures).

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: GL_QUAD_STRIP + textures

    Ok, thank you for your reply
    That's all I needed to know.
    Hylke

Similar Threads

  1. gl_quad_strip
    By Jiggered in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-23-2012, 04:04 PM
  2. GL_QUAD_STRIP
    By johnnyp05 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 10-11-2005, 01:16 AM
  3. GL_QUAD_STRIP Texturing
    By Amir in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 12-22-2004, 03:14 PM
  4. GL_QUAD_STRIP
    By Ozzy in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-30-2002, 05:28 PM
  5. Lit GL_QUAD_STRIP??
    By in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-14-2001, 03:44 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