**
This whole discussion makes me think:
For software rendering, SDL 1.2 is still the best bet?
I mean, does the software rendering within SDL2 (eighter using
SDL_CreateSoftwareRender or the software fall back of the SDL_CreateRender,
not sure if there is differences) performs WORSE than the one in SDL 1.2? I
really want to know the answer…
My football games Eat the Whistle ( http://sourceforge.net/projects/etw/ )
has been migrated a few months ago to SDL 2.0 to go mobile (now there are
iOS and Android versions available), it uses internally a 8bit chunky pixel
surface, where all the gfx operations take place and then it’s blitted to
the screen.
In the SDL 1.2 version I had to keep the 8bit bitmap to the size of the
screen, or manually scale it while rendering.
The 2.0 target improved this since using SDL_RenderSetLogicalSize() I can
keep the size of the objects on the screen under control.
Here is a “cut & paste” of the screen initialization (error check omitted
for brevity):
screen = SDL_CreateWindow(“ETW”/-/, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 0, 0, SDL_WINDOW_BORDERLESS |
SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_SHOWN);
renderer = SDL_CreateRenderer(screen, -1, 0);
SDL_RenderSetLogicalSize(renderer, WINDOW_WIDTH, WINDOW_HEIGHT);
To get some speed on slower devices I use 16bit depth textures:
screen_texture = SDL_CreateTexture(renderer,
SDL_PIXELFORMAT_RGB565,
SDL_TEXTUREACCESS_STREAMING, WINDOW_WIDTH, WINDOW_HEIGHT);
This is how I transfer my 8bit chunky pixel buffer to the texture:
void blitScreen16(uint16_t *dst)
{
uint8_t *src = main_bitmap;
int x, y;
for (y = bitmap_height; y > 0; y--)
for (x = bitmap_width; x > 0; x--)
*(dst++) = palette16[*src++];
}
And here is the display code:
if(!SDL_LockTexture(screen_texture, NULL, &pixels, &pitch)) {
if (pitch == bitmap_width * 2)
blitScreen16(pixels);
else if (pitch == bitmap_width * 4)
blitScreen32(pixels);
else {
D(bug("Unsupported pitch: %d (width %d)\n", pitch,
bitmap_width));
}
SDL_UnlockTexture(screen_texture);
SDL_RenderCopy(renderer, screen_texture, NULL, NULL);
SDL_RenderPresent(renderer);
}
This is as fast in desktop OSes as what I was doing before (SDL_BlitSurface
- SDL_Flip).On Mon, Apr 8, 2013 at 4:48 AM, RodrigoCard wrote:
–
Bye,
Gabry