Sign in to follow this  
msrb

SDL perfomance issues

Recommended Posts

Hi, in a game i am making using SDL i need to read/write pixels from/to surfaces. The problem is i need to use hardware surfaces or else the game is REALLY slow, but if i do i cant mess directly with pixels (at least i dont know how, i keep getting error). Is there a way to read pixels from hardware surfaces?? And, are software surfaces suppose to be drawn really slow ?

Share this post


Link to post
Share on other sites
Software surfaces can be faster than hardware surfaces. Software surfaces can use the "memory blit" feature of some graphics chips. If you find you need to read and write individual pixels a lot then software surfaces may be better.

If you find you are only WRITING pixels and not READING them you can use OpenGL with the hxRender library you can get better hardware performance than SDL alone. See the webpage for details.

Share this post


Link to post
Share on other sites
i need to both write and read pixels. And as far as i can see i cant use software surfaces cause they really take forever to be drawn. What can i do to draw software surfaces faster than hardware. Till today i have a window

screen = SDL_SetVideoMode (1024,768, 16 ,SDL_SWSURFACE| SDL_DOUBLEBUF |SDL_FULLSCREEN);

or this
screen = SDL_SetVideoMode (1024,768, 16 ,SDL_SWSURFACE |SDL_FULLSCREEN );

and then i draw the surfaces using blisurface.
I am doing something wrong??
Is there something missing ??

[Edited by - msrb on June 10, 2006 5:13:01 PM]

Share this post


Link to post
Share on other sites
Why do you need to read from the surfaces? Why do you need to write to them? How often is it done?

You need to SDL_LockSurface() a hardware surface to read or edit it, and SDL_UnlockSurface() it after, but this is horribly slow, annd not advised.

Share this post


Link to post
Share on other sites
well i need it cause i am trying to implement a system of lights and shadows.

It is very frequent (every cicle).

I locked the surface but i thing it just froze.

I cant see any other way of doing this except to blit an image that is a single white pixel with alpha-blending :P, but even this requires reading pixeis to find out the invisivel pixels.

Share this post


Link to post
Share on other sites
In general, SDL doesn't perform well enough to be used at higher resolutions like 1024x768. Consider using 640x480 or 800x600.

Or switch to OpenGL for rendering.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this