[SDL] SDL novice questions....
koshmaar at poczta.onet.pl
Fri Aug 12 16:22:24 PDT 2005
> there way to use singlethreaded SDL, I could live without events, timers,
> etc. Is there any other solution to singleton problem, or I have to write
> thread safe singletons?
AFAIK, you have to use multithreaded DLL in VisualC++ (I think you're using it because its the only C++ compiler I know, which allows you to change single / multi threaded library versions... but may be wrong, haven't used many of them). Also, there's nothing such as "singlethreaded SDL" - you don't need to use events, timers etc. if you don't want to, but you don't know / can't change what SDL is using at certain platforms. And on some of them, some features may be implemented using threads (ie. events queue).
>Can I expect more problems because of multithreading?
If you aren't using multithreading explicitely, then you shouldn't have any problems. If you are using multithreading explicitely, then your on your own, you have to design your code in such a way so that it'll be thread safe. And in that case - yes, you may run into some not-trivial problems.
> Another question is that I am blitting 640x480 image and I get 58 fps on
> geforce 6600. It seems thats because my image surface is in system memory. How
> can I load image into video memory? I open hw display and double buffering in
> fullscreen and that works, I checked flags, but I cant figure out how to load
> image into vidoe memory, is that possible with SDL?
You can't always have all surfaces in video memory, there's always probability that your platform / video card doesn't support storing surfaces in it.
However, if you'd like to have surface stored in video memory, try passing SDL_HWSURFACE to function which creates your surfaces. Then, you can check whether it's stored in video-ram using this code:
if (0 == (surface->flags & SDL_HWSURFACE))
fprintf(stderr, "This surface isn't stored in video memory");
Also, I'd suggest to use SDL_GetVideInfo() to obtain current video mode specs, and check for hw_available.
Btw, in OpenGL all textures are stored in video memory, so if performance is very important to you, and you plan many blits, IMHO you should try OGL - it is very easy to setup and use with SDL.
More information about the SDL