Jump to content

  • Log In with Google      Sign In   
  • Create Account


SDL.Net Questions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 DaveWH   Members   -  Reputation: 108

Like
0Likes
Like

Posted 17 July 2012 - 06:28 PM

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?

Sponsor:

#2 6677   Members   -  Reputation: 1054

Like
2Likes
Like

Posted 18 July 2012 - 04:55 PM

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)

#3 DaveWH   Members   -  Reputation: 108

Like
0Likes
Like

Posted 20 July 2012 - 03:47 PM

Well +1 for being the only person to bother answering me. Posted Image 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*

#4 6677   Members   -  Reputation: 1054

Like
0Likes
Like

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.

#5 DaveWH   Members   -  Reputation: 108

Like
0Likes
Like

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS