[SDL] glSDL Texture sizes

Bob Pendleton bob at pendleton.com
Mon Nov 10 13:31:01 PST 2003


On Mon, 2003-11-10 at 13:50, Gabriel Gambetta wrote:
> > Another reason why I haven't messed with it is that this code should
> > be redesigned, using a texture space allocator (a 2D memory manager, 
> > basically; able to use a single texture for lots of surfaces and 
> > stuff like that), but that's still a TODO for the backend version.
> 
> What good algorithms exist for that? I have a very similar need,
> although
> not directly related. I've tried using a quadtree and 2D BSP trees but
> the results weren't good (lots of space wasted)

Yeah, this is a variation of the knapsack problem and is fairly hard to
solve. I worked on it once. We found that the problems were caused by
fonts. Lots of little glyphs cause horrible fragmentation. So, we built
a special purpose allocator for fonts. It found the largest glyph and
then tried to tile the font into a single large region or several
smaller regions. Doing that got us past the worst of the fragmentation
problems. 

We didn't try anything as complex as a bsp tree. We just broke up square
regions into smaller square regions and kept the free squares on a list,
one list for each size. Basically just a variation of the memory
allocators used by malloc() and friends. 

			Bob Pendleton


> Thanks,
> 	--Gabriel
> 
> Lic. Gabriel Gambetta
> ARTech - GeneXus Development Team
> ggambett at artech.com.uy
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
-- 
+---------------------------------------+
+ Bob Pendleton: writer and programmer. +
+ email: Bob at Pendleton.com              +
+ web:   www.GameProgrammer.com         +
+---------------------------------------+





More information about the SDL mailing list