SDL.Net Questions

Started by
3 comments, last by DaveWH 11 years, 9 months ago
I have a couple noobish questions about SDL.Net. The first is this:

Every SDL or SdlDotNet tutorial I have seen has used a defined Surface as the main screen. For example
[source lang="csharp"]private static Surface videoscreen;
videoscreen = SetVideoMode(800, 600, 16, false, false, false, true);
videoscreen.Fill(Color.Black);
videoscreen.Blit(sprite);
videoscreen.Update();[/source]
However, while trying to build a game with SdlDotNet I noticed that I can simply use Video.Screen for any action I normally would have preformed on the Surface screen. For example:
[source lang="csharp"]Video.SetVideoMode(800, 600, 16, false, false, false, true);
Video.Screen.Fill(Color.Black);
Video.Screen.Blit(sprite);
Video.Screen.Update();[/source]
Is there a reason why everyone still uses a defined Surface? I'm assuming there is some sort of performance or stability issue that I haven't encountered within the scope of my little game, but I would like to know in case I might run into trouble later on.

My next question is about freeing unused surfaces. I understand that it is good practice to free any surfaces that are no longer in use while the program is running to free up memory space, but is it necessary to free all surfaces when the program closes? Can Windows (or other OSs) tell that the program associated with that memory space is no longer running and allow other programs to use it? If the program using SDL crashes what happens with the allocated memory?
Advertisement
First question I can't help you with.


but is it necessary to free all surfaces when the program closes?

Well once the program closes any modern OS should just kill the thread and remove it from RAM etc so you should be fine but I've seen java staying open using my RAM even when its not being used so clearly some things can slip through the net. I think its just a good practice to stick to more than anything (and well, don't want your game slipping through the RAM clearup purge)
Well +1 for being the only person to bother answering me. tongue.png The first question earned me the Tumbleweed award on Stack Overflow. It appears that either: a) no one knows or b) no one cares. *sigh*
I guess if everyone uses the defined surface then you might aswell use it aswell.

Rereading the code I think it might be possible to have multiple surfaces to draw onto, might be harder with the second method, not using SDL.NET thats probably wrong.
Well you can draw onto any surface, but that I know of you only have one screen (unless you can somehow use more for buffering purposes). I'm realy not happy with the "follow the leaders" idiology here though. The reason I started doing it that way is because it was easier than what I was trying to do by passing a reference to the screen object into all the classes that needed access to it. I realize now that I could have just implimented the screen as public static for that reason though.

This topic is closed to new replies.

Advertisement