I've been sick for couple of days so I decided to do some less demanding programming and since there is some kind of problem with latest "legacy" SDL 1.2.15 I decided to jump to 2.0. I'm in a middle of the process and there is lot of guessing going on, but here are some thoughts.
The first project for 2.0 is Teemu, because it has the most light-weight GUI you can imagine. It has only graphical ascii letters with some background tiles and a title logo image. There are some classes with simple color data, then a surface class and gui for the window etc.
SDL 2.0 has some major changes in keyboard handling and in graphics. If the keyboard codes work as I think then unicode is not needed anymore, in fact there is no unicode field anymore in the keyboard data, only keycode and scancode. Some keyboard codes have changed, for example keypad codes are now ...KP_1 rather than KP1. I don't yet know how keyboard events works since keyboard repeat has been removed or moved and there is a new event for keyboard which is SDL_TEXTINPUT. It could be more suitable for turn based input, who knows?
New features in graphics are window, renderer and textures. I've always worked only with software rendering so I don't have experience from textures, but as far as I can understand textures are now the only way to display graphics. Surfaces still exists, but they are only data for images and allow pixel based operations where textures are static. Renderer is the canvas where textures are displayed and you can create textures from surfaces. I don't know how colorkey works with textures. It may have to be replaced with alpha blend value, but I guess it's quite easy to create alpha images from colorkey information by manipulating the alpha value of a surface.
So my plan is to replace destination surface in surface class with renderer. Then I guess the slow way to display images is create the texture before it's displayed and fast way is create and store the texture during the constructor of the class. I guess(?) textures are copied in the GPU which makes them faster, but the copy process itself is slow. And that there is of course limited memory for textures in GPU.
All this is speculation, but it shouldn't be too long to see what happens.
No comments:
Post a Comment