SDL perfomance issues
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 ?
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.
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.
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]
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]
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.
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.
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.
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.
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.
Or switch to OpenGL for rendering.
If the thought of using OpenGL for 2d drawing scares you just use the hxRender library I linked to in my previous post.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement