Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Creating some kind of "tiling"

This topic is 5128 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
    glTexCoord2f(rect.x/size, 1-rect.y/size);

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

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

    glTexCoord2f(rect.x/size, 1-(rect.y+rect.h)/size);
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

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!