Jump to content
Sign in to follow this  
dantay9

Window Flickering on Redraw

Recommended Posts

dantay9

I am remaking my Yahtzee game because the old one was unreliable. Because I need reliability, I decided to draw the controls onto the window instead of actually having controls. I was going to use GDI+, but then AdmiralAlkex brought up the idea of using SDL instead of GDI+. This seems to have simplified a lot of the code as well as make it move along a little faster.

My only problem is the RefreshGUI() method. When called, it paints the background over top of all other controls effectively allowing me to redraw the controls again. This is used when a score changes because I can't draw a new score over top of the previous score (which would be 0). So I have to redraw everything. The result of redrawing the whole screen is the flicker that is produced while drawing.

I was wondering if there was a way to "double buffer" SDL like you can with GDI+. Or maybe there is another way?

Here is the download for the files in the correct directory structure (very important).


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites
AdmiralAlkex

I almost didn't see you there on the seventh page :idea: (topics per page @ 30)

So yeah, there is the $_SDL_DOUBLEBUF but I think that only works in HW and Fullscreen mode, so it's not very useful here I imagine.

BUT the flickering could be reduced greatly by simply updating the screen less. Remember that _SDL_Flip($pSurface) moves the whole surface to the screen, and it should only be done when you want to see something new, not like you do here where you update every time you copied something to $pSurface.

A quick hack that seems to remove the (noticeable) flickering with the scores is to remove UpdateGUI() from DrawImage() and add UpdateGUI() to the bottom of RefreshGUI().

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
dantay9

That definately did it. Thanks for the help. I really like using SDL. I think it is much easier than using GDI+, especially when you want to draw stuff on top of a background. That normally takes a while in GDI+.


[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

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  

×