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?
4 replies to this topic
Ad:
#2 Members - Reputation: 1050
Posted 18 July 2012 - 04:55 PM
First question I can't help you with.
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)but is it necessary to free all surfaces when the program closes?
#4 Members - Reputation: 1050
Posted 20 July 2012 - 03:52 PM
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.
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.
#5 Members - Reputation: 108
Posted 20 July 2012 - 03:58 PM
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.






