Sign in to follow this  
DaveWH

SDL.Net Questions

Recommended Posts

DaveWH    108
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?

Share this post


Link to post
Share on other sites
6677    1054
First question I can't help you with.

[quote name='DaveWH' timestamp='1342571297' post='4960272']
but is it necessary to free all surfaces when the program closes?
[/quote]
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)

Share this post


Link to post
Share on other sites
DaveWH    108
Well +1 for being the only person to bother answering me. [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] 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*

Share this post


Link to post
Share on other sites
6677    1054
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.

Share this post


Link to post
Share on other sites
DaveWH    108
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.

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