Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thomas, 2008-02-04, "Texture Atlas"
Thomas Offline
Frictional Games

Posts: 2,634
Threads: 184
Joined: Apr 2006
Reputation: 68
#1
Thomas, 2008-02-04, "Texture Atlas"

The texture atlas was one of the first thing that I implemented in the engine. It was actually something I started working on the day work started for Energetic, which also means the code is a bit messy Smile So I decided an update was needed.

So what is a texture atlas? Basically it is something that has been made to solve two major problems when rendering 2D GUI stuff (fonts, HUD, menus,etc):
1) One usually want this kind of graphics in non-power-of-two sizes like 23x43, 3x19, etc. But these kinds of sizes are not supported by most graphics hardware.
2) One wants to draw alot of different images on screen at once. However, 3d cards work best when a lot of things can be drawn at once and having 100 images using different texture is going to be slow.
The solution is to many images sharing the same texture. That way you can have any size you like and many images can be drawn at the same time!

One of the biggest problem with the current code was that a deleted image continued to use memory until all of the images sharing the same texture was deleted. To fix this I decided to add all images on the same texture again once an image was deleted and skipping the deleted image. While working on this code, it hit me that I could sort the images before adding them again, making them fit better, which would save quite a bit of memory. Since I could not do this every time an image was added, I decided on only sorting the images on a texture once an new image did not fit and then see if it fitted after the reorganisation. This way turned out to work great.

So now the engine has a system that can delete images without wasting memory and also saves alot of memory when saving the bitmaps Smile

Attached are pictures of one texture with unsorted images and one where the images are sorted.
02-04-2008, 08:05 PM
Find
WindexGlow Offline
Posting Freak

Posts: 1,108
Threads: 70
Joined: Mar 2007
Reputation: -5
#2
RE: Thomas, 2008-02-04, "Texture Atlas"

I bet you're good at tetris. Fog blog anyone?

EDIT: Even though you guys probably can't do much about it, the server downtime/limitation is starting to get on my nerves.

Please -REP me.
Honestly, please do. I want to see how low I can go!!
Ignore that error message too. Just ignore it and keep going to give me -rep.
02-05-2008, 07:15 AM
Find




Users browsing this thread: 1 Guest(s)