The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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


Messages In This Thread
Thomas, 2008-02-04, "Texture Atlas" - by Thomas - 02-04-2008, 08:05 PM



Users browsing this thread: 1 Guest(s)