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 5 of 5

Thread: texturing

  1. #1
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    36

    texturing

    I have this problem. I need put a texture 32x32 (square) on a rectangle (32x3 x 32 )
    Code :
    glBegin(GL_QUADS);	
      glTexCoord2f(0.0f, 0.0f);	
      glVertex(VERT[0] ); 
      glTexCoord2f(1.0f, 0.0f);
      glVertex(VERT[1] );
      glTexCoord2f(1.0f, 1.0f);	
      glVertex(VERT[3] );
      glTexCoord2f(0.0f, 1.0f);			
      glVertex(VERT[2] );
    glEnd();
    this code works, but the sqaure texure is strech on rectangle....I'd like repeat the 32x32 texture 3 times on rectangle. HOw ca I do? Thanks
    Mickey

  2. #2
    Intern Newbie
    Join Date
    Jan 2006
    Location
    Pacific Northwest
    Posts
    41

    Re: texturing

    You need to use values larger than 1.0f in your calls to glTexCord2f() if you want to wrap. You can also control wrapping with glTexParamteri(), for example, if you want black displayed instead of wrapping or streching.
    Code :
    glTexCoord2f(6.0f, 6.0f);
    glVertex3f(vert1, vert2, vert3);
    "The first person to succeed is the first person to make 100 mistakes" - Albert Einstien

  3. #3
    Intern Newbie
    Join Date
    Jan 2006
    Location
    Pacific Northwest
    Posts
    41

    Re: texturing

    So if you wanted it repeated 32 times, use glTexCoord2f(32.0f, 32.0f);
    ....
    "The first person to succeed is the first person to make 100 mistakes" - Albert Einstien

  4. #4
    Intern Newbie
    Join Date
    Dec 2005
    Posts
    36

    Re: texturing

    eg I've got a rettangle 1x3 units; my texture is 1x1 units; I need repeat this texture 3 times on rectangle to don't stretch or shrink;
    Furtermore: I have a rectangle 2x3 units; I need repeat texture 6 times on this rectangle; dimension of rectanggle can be nxm and I need a way to assigne textCoord in relation to its dimensions (units). How can I do? Thanks
    Mickey

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,749

    Re: texturing

    With using some simple maths (like Joe said) and your brain

Posting Permissions

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