CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Posts
    99

    Unhappy flashy when refresh()

    hello guys,

    i'm implementing a simple game with c#. question is how to redraw the window form.

    my game loop is really simple:

    while (!stop)
    {

    gl.gamelogic();

    Refresh();

    //Update();

    Application.DoEvents();

    }


    i have tried both refresh and update.

    update doesn't really redraw the form immediately unless i resize the form.

    refresh redraws the form immediately, but the resulting animation looks really flashy.

    how can i get rid of the flashy result? thanks

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: flashy when refresh()

    You need to double buffer the image that you are drawing. This means that you draw the image in memory and then blt it to the screen very quickly. You can do this very easily in .NET:

    Code:
    public MyControl( )
    {
        SetStyle( ControlStyles.UseOptimizedDoubleBuffer, true );
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured