Monday 30 November 2015

SDL: Surface and texture

Teemu is running again, but as expected graphics were problematic. Fonts had reversed R and B components I think and when I tried to include texture as component in Image_Data class with surface it just didn't work.

That's why I created Texture class for static textures only and then Image_Data for SDL surface. That way I can manipulate the surface by first creating it and then adjusting stuff. For example fonts are created from only one template color which is much easier than use paint program to draw all colors. Surface class can unify all graphics data to RGBA model, because colorkey doesn't matter I guess. In texture the transparency is done with alpha blending value so alpha channel can be reconstructed in SDL surface using the colorkey.

If software drawing is an option then Image_Data can be used as it is. The texture is just a static copy of a surface data.

Other than that I think moving to SDL 2.0 was relatively easy. Keyboard has still some problems, because I had unicode routines receive ASCII for now which only works for letters. If the routine can't be fixed to return all ASCII codes (from keycode data) then I have to rewrite that, but it's a minor problem.

No comments: