Sdl questions

Hello

I am new to sdl, therefor i have few questions.

I’ve made simple example that “drags” 2 bitmaps (surfaces) around. And
i wonder why it is so slow ! the same thing writen in pure DX is 2 or
maybe even 3 times faster. The code is simple. (i’ve attached it).
Same code, after timers replacement for linux ones is slow on X’s too.
I have Pentium III 1.1 Ghz and 512 of ram and GeForce 3 with 64 mb of ram (not any mx).

Example requires 2 color bitmaps, 640x480.–
Best regards,
Grzegorz mailto:@Grzegorz_Jaskiewicz
-------------- next part --------------
A non-text attachment was scrubbed…
Name: main.cpp
Type: application/octet-stream
Size: 2258 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20020420/fcb1fd13/attachment.obj

I’ve made simple example that “drags” 2 bitmaps (surfaces) around. And
i wonder why it is so slow ! the same thing writen in pure DX is 2 or
maybe even 3 times faster. The code is simple. (i’ve attached it).
Same code, after timers replacement for linux ones is slow on X’s too.
I have Pentium III 1.1 Ghz and 512 of ram and GeForce 3 with 64 mb of ram (not any mx).

Hi,

You are setting the screen video mode to 16bpp, but you do not apply any
post-treatment to your images once they are loaded. It might be, that
the surfaces you load are in 24bpp, and in this case they have to be
converted to 16bpp each time you blit them, which is terribly slow. You
should make sure they are converted to the same format as your screen
surface, especially if you want to use hardware acceleration. Use
SDL_DisplayFormat for that.

Another hint is that maybe your real screen depth is not 16bpp. In this
case, say if you are using 24bpp, the SDL buffer has to be converted
from 16bpp to 24bpp in order to be displayed, which is very slow as
well. Using SDL_VideoModeOK will help you determining which depth you
should use.

A clever use of SDL_DisplayFormat and SDL_VideoModeOK should provide you
with programs that are as fast as DirectX, but much more portable -
provided you restrict yourself to standard C and do not include stuff
like windows.h and such! :slight_smile:

Hope this helps!
Alex.–
http://www.gnurou.org

Probably because the images are in a different format than the screen is in,
so it’s using software code to blit instead of hardware accelerating them.
Use SDL_DisplaySurface() to convert them.

-Jason> ----- Original Message -----

From: gj_22@wp.pl (Grzegorz Jaskiewicz)
To:
Sent: Saturday, April 20, 2002 1:13 PM
Subject: [SDL] sdl questions

Hello

I am new to sdl, therefor i have few questions.

I’ve made simple example that “drags” 2 bitmaps (surfaces) around. And
i wonder why it is so slow ! the same thing writen in pure DX is 2 or
maybe even 3 times faster. The code is simple. (i’ve attached it).
Same code, after timers replacement for linux ones is slow on X’s too.
I have Pentium III 1.1 Ghz and 512 of ram and GeForce 3 with 64 mb of ram
(not any mx).

Example requires 2 color bitmaps, 640x480.


Best regards,
Grzegorz mailto:gj_22 at wp.pl

Unless the framebuffer and the bitmaps you’re using share the same pixel format,
SDL will have to perform format conversions on the fly. This is slow.

Have a look at the SDL_DisplayFormat function. I bet this will speed up the
framerate considerably.

-JohnOn Sat, Apr 20, 2002 at 07:13:26PM +0200, Grzegorz Ja?kiewicz wrote:

Hello

I am new to sdl, therefor i have few questions.

I’ve made simple example that “drags” 2 bitmaps (surfaces) around. And
i wonder why it is so slow ! the same thing writen in pure DX is 2 or
maybe even 3 times faster. The code is simple. (i’ve attached it).
Same code, after timers replacement for linux ones is slow on X’s too.
I have Pentium III 1.1 Ghz and 512 of ram and GeForce 3 with 64 mb of ram (not any mx).


John R. Hall - KG4RUO - Stranded in the Sol System
Student, Georgia Tech; Author, Programming Linux Games