Creating some kind of "tiling"

Started by
0 comments, last by Hedos 19 years, 11 months ago
Hey, I''m currently working on a GUI for my game. I have a file, GUI.tga who hold all the images required to draw windows, like corners, borders, background, etc... This is what I am using to draw an image from the texture:

static void DrawRect(Rect &rect, Rect2 &Vertex)
{
  float size=128;
  glBegin(GL_QUADS);
    glTexCoord2f(rect.x/size, 1-rect.y/size);
    glVertex2f(0,0);

    glTexCoord2f((rect.x+rect.w)/size, 1-rect.y/size);
    glVertex2f(Vertex.w,0);

    glTexCoord2f((rect.x+rect.w)/size, 1-(rect.y+rect.h)/size );
    glVertex2f(Vertex.w,Vertex.h);

    glTexCoord2f(rect.x/size, 1-(rect.y+rect.h)/size);
    glVertex2f(0,Vertex.h);
  glEnd();
}
Rect is a struct, containing: x,y,w,h (w=width h=height) Rect2 is the samething but it only contains w and h Rect represent the location of the picture inside my GUI.tga texture and Rect2 represent the size of the texture to be drawn on the screen... Right now, if Rect2 is a different size from Rect, the texture will just be "streched"... But what I would like to do, is make my texture drawn on the screen to always keep the same size but only be kinda like "tiled".. And I can''t figure out how to do that as my textures are located inside a big texture... :/ Any idea? Thanks
Advertisement
To tile the textures, you have to pick out the ''tile'' from the source texture, and then you have to draw the texture multiple times -- you cannot (to the best of my knowledge) use another RECT and expect OpenGL to give you tiling capability.
- fyhuang [ site ]

This topic is closed to new replies.

Advertisement