Results 1 to 4 of 4

Thread: Getting textures to tile across a poly

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Milwaukee WI 53211
    Posts
    29

    Getting textures to tile across a poly

    I think I use GL_REPEAT to get a texture to tile across a rectange, but its not working. I know I'm missing something basic. Below are the settings I use for every texture:

    glTexEnvf(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MO DULATE);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL _REPEAT);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL _REPEAT);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Getting textures to tile across a poly

    How do you setup your texture coordinates?

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2001
    Location
    Milwaukee WI 53211
    Posts
    29

    Re: Getting textures to tile across a poly

    I have a Poly class that has a draw function that looks like so:

    void Poly::draw()
    {
    glBindTexture(GL_TEXTURE_2D,textureID) ;

    glBegin(GL_QUADS);

    glColor3ub(hColor.red,hColor.green,hColor.blue);

    glTexCoord2f(0.0,1.0);
    glVertex3f(hLocalVertices[0].x,hLocalVertices[0].y,hLocalVertices[0].z);

    glTexCoord2f(1.0,1.0);
    glVertex3f(hLocalVertices[1].x,hLocalVertices[1].y,hLocalVertices[1].z);

    glTexCoord2f(1.0,0.0);
    glVertex3f(hLocalVertices[2].x,hLocalVertices[2].y,hLocalVertices[2].z);

    glTexCoord2f(0.0,0.0);
    glVertex3f(hLocalVertices[3].x,hLocalVertices[3].y,hLocalVertices[3].z);

    glEnd();
    }

    Right now I only have it drawing quads.

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2000
    Location
    Moscow,Russia
    Posts
    11

    Re: Getting textures to tile across a poly

    You must specific setup texture coordinates..
    for example:

    glBegin(GL_QUADS);
    glTexCoord2d(0,0); glVertex2d(-4,-4);
    glTexCoord2d(0,2); glVertex2d(-4, 4);
    glTexCoord2d(3,2); glVertex2d( 4, 4);
    glTexCoord2d(3,0); glVertex2d( 4,-4);
    glEnd();

    so you get 3 horiz & 2 vert texture

Similar Threads

  1. Is it possible to tile chipped textures?
    By Bhoot123 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 08-24-2018, 04:12 AM
  2. Tile troubles
    By Rapzoph in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-10-2011, 05:08 AM
  3. 3D tile visibility
    By ugluk in forum OpenGL: General
    Replies: 12
    Last Post: 08-02-2010, 10:16 AM
  4. Tile texture
    By mishuk in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-13-2003, 08:16 AM
  5. see-thru tile problems
    By Xero_Tolerance in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 05-27-2002, 05:31 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