HOWTO: GetDrawingSurface(), Release(), CreateFromScreenShot() and Wait(1)

Started by Monsieur OUXX, Tue 11/06/2013 22:40:53

Previous topic - Next topic

Monsieur OUXX

In my game, I do a lot of drawing onto the BackgroundGraphics of one GUI.
I do it in repeatedly_execute_always.
I have a loop that updates various graphic items on that BackgroundGraphics's surface : I do a bit of drawing, then call "Release()" (to update the display memory), and then "GetDrawingSurface()" again (to start drawing again) -- several times in one game loop.

The reason why I'm doing it little by little is because I need the display to be up-to-date (if not on-screen, at least in memory), because I also use "DynamicSprite.CreateFromScreenShot" (to save the aspect of some of those graphic items, without requiring to redraw them) and I want the created sprite to contain the lastest screen update.

Since I'm inside repeatedly_execute_always, I can't call Wait(1) to force-update the display.

Despite calling Release on my drawing surface, the "CreateFromScreenShot" snapshots are always one frame off.

I don't know what I'm doing wrong. Do you see if I'm wrong in my reasoning? Do you have general advice regarding the use of these functions?
 

Khris

Calling Release() only to get the same Drawingsurface immediately afterwards is most likely completely useless. It's like saving and closing a word document only to open it again, without doing anything in between.
Like you said, you're updating the part of memory that contains the surface, but it hasn't been drawn yet, and thus CreateFromScreenshot will never reflect these updates in the same loop.

Even if you used repeatedly_execute always instead, calling Wait(1) would slow the game speed down to 50% afaik, if not block it completely.

You have to find another way.

Monsieur OUXX

Quote from: Khris on Tue 11/06/2013 23:02:41
Like you said, you're updating the part of memory that contains the surface, but it hasn't been drawn yet, and thus CreateFromScreenshot will never reflect these updates in the same loop.

Damn.

Nevermind. I think I'll just take my screenshot once at the very beginning of the game loop, and then use this outdated version for all the drawings in the loop. I think this will fool the end-user's eye.
 

SMF spam blocked by CleanTalk