[SDL] Decomposing a SDL surface

Sebastian Beschke sebastian.beschke at student.uni-tuebingen.de
Thu Jun 29 07:49:14 PDT 2006


Hi,

I'm not really an expert in that field, but I'd be guessing that this 
method, in whatever way you implement it, would be to slow (switching 
active textures takes time AFAIK) to justify implementing that 
optimization. Better waste a couple of pixels of texture memory (judging 
from your example, it also doesn't seem as if your textures are huge) 
and save lots of development time, is my opinion. ;)

Sebastian

jorgefm at cirsa.com wrote:
>
> Hello all,
>
> First of all, it's a bit little of topic.
>
> I was wondering if anybody knows a method to decomposing a surface in
> the next way. The idea is to map this surface rects in openGL textures
> and avoid wasting texture memory from the transparent pixels.
>
> First, I want to discard the transparent pixels from the surface. For
> the visible ones, I want to group them in rectangles, the biggest
> available. The next figure try to show this:
>
>  ............
>  ....wwww....
>  .yyyxxxxzzz.
>  .yyyxxxxzzz.
>  .yyyxxxxzzz.
>  ....vvvv....
>  ............
>
> The '.' are transparent pixels, the different letters show the 5
> decomposing rectangles. The different rects maps to different size
> textures (256x256 for the 'x', 128x128 for the 'y' and 'z', and
> 128x32 for the 'w' and 'v' rects, for instance).
>
> The 'w' and 'v' rects are not allowed to be in 'x' rect to avoid the
> texture junction problem on rotate texs. This problem arise if there
> are vertexs from one rectangle not overlapping the vertexs of the
> next rect.
>
>          0--------0
>          |        |
>     0----0        0----0
>     |    |        |    |
>     |    |        |    |
>     |    |        |    |
>     0----0        0----0
>          |        |
>          0--------0
>
> The solution is providing more rects, the 'w' and 'v'.
>
>          0--------0
>          |        |
>     0----0--------0----0
>     |    |        |    |
>     |    |        |    |
>     |    |        |    |
>     0----0--------0----0
>          |        |
>          0--------0
>
> Then, anybody knows some algorithm to solve this decomposing
> in a, more or less, efficient way ? Any comment is welcome.
>
> Best regards,
> Jorge
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl
>   





More information about the SDL mailing list