Answer the question
In order to leave comments, you need to log in
C# How to get rid of flicker?
I have read about 100 articles already, but of course it’s worth complicating it a little, and hello flicker, 4 lines cannot be drawn.
I'm already doing Double Double Tribol buffer, and probably tried 32 combinations. + I also give the form itself doubleBuffer=true and I've mixed all this a million times already, nothing helps.
/// Form1.cs
GameManager = new GameManager{
PaintDilegate = () => this.panelGame.Invalidate(),
PaintInitDilegate = (PaintEventHandler fun) => { this.Paint += fun; },
};
GameManager .init();
}
///////////////////////////
///////// GameManager.cs
class GameManager {
/////
Bitmap DoubleBuffer;
Graphics gBuf;
public init(){
this.PaintInitDilegate?.Invoke( Paint );
}
public void Paint(object sender,PaintEventArgs e)
{
e.Graphics.DrawImage(DoubleBuffer,0,0);
}
/// вызывается в таймере постоянно
public void update(object srnder,PaintEventArgs e){
if(DoubleBuff==null || (DoubleBuf.Width!=Width){
DoubleBuf?.Disponse();
DoubleBuffer = new Bitmap(Width, Height);
gBuf = Graphics.FromImage(DoubleBuffer);
initMap(); // ... нарисовать карту
}
Game.Map.ForEach( (x,y,brushIndex)=>{
///..................
gBuf.FillRect( ....);
}
PaintDilegate?.Invoke(); // отослать панели команду перерисовать
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question