Jump to content
  • Advertisement


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


One big texture (512x512) containing others for menu.

This topic is 5584 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

My problem is this. I need to make a menu for my game and I dont want to have many different textures, for memory reasons. So how would I create a texture sized 64x32 from a texture with images inside. I hope you understand my question, its 12:25pm here and Im sleepy.

Share this post

Link to post
Share on other sites
I think I do, you mean to tell use you''ve put a bunch of GUi pictures together in a large image... Say the Upper-left holds the picture for the ''OK'' button and the Upper-Right holdes the picture for a fancy textbox background.

Is that right?

Well, assuming it is, what you want to do is perfectly possible! And there''s two ways to do it.

Of course, ''for memory reasons'' is a sorry excuse, you''ll have as much data in a large surface holding your data than in eight or so smaller textures holding the same data together... But I''ll still run you through two solutions.

#1: Load the big surface, build small textures from it.
With this method you wind up with only one media file (the big .bmp) in memory but several small textures for your GUI. The pseudocode goes about like this:
-Load big BMP in a surface (not a texture) located in system memory.
-Ready textures at the appropriate sizes
-For each texture, lock its surface and load it from the appropriate bytes in the big surface.

#2: Use varying coordinates with a single texture.
If you make a quad, you don''t have to define the UV coordinates as being 0.0f and 1.0f. If you just need the Upper-Left of the texture, go ahead and put 0.0f and 0.5f''s as your coords.
I expect you''ll run into a small problem though: With bilinear filtering, data from a pixel just outside your expected texture will bleed in your buttons... Say you have a gray button with a yellow window to its right in the big BMP, well showing the gray button just stretched a bit might give you some yellowish gray on the right.

I hope these avenues get your brain started up.

=^.^= Leaders and teachers should remember: It is best to offer others what they Need, not what they Want.

Share this post

Link to post
Share on other sites
Thank you for your reply.

That is what I wanted, you got the point. But your last words make me think if I should do it and if it wont save me any memory but just make my project harder, I might not.

Thanks though

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!