G
Guest
Hi,
I have recently begun developing an application for PDA's running PocketPC
2003. To break it down, in essance it is a drawing package using vector
graphics. However I have had a real problem trying to get flicker free
drawing to the screen of a PDA (it seems to work fine on the emulator but not
on the actual device).
I understand the basic principle of having a back buffer for drawing to, and
then a front buffer (sorry if the terminology is wrong, I am new to all this)
which you then update to the back buffer when everything is drawn. The way I
do this is as follows:
public class Device : Control
{
...
private System.Drawing.Bitmap back;
...
private System.Windows.Forms.Timer timer;
...
public Device(int width, int height, Control owner)
{
....
this.timer = new Timer();
this.timer.Interval = 33;
this.timer.Enabled = true;
this.back = new Bitmap(width, height);
...
this.timer.Tick +=new EventHandler(timer_Tick);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(this.back,0,0);
}
public void BeginScene()
{
...
}
public void EndScene()
{
...
}
public void AddPrimitive(IDrawable primitive)
{
....
}
private void timer_Tick(object sender, EventArgs e)
{
if(this.updated)
{
this.Invalidate();
}
}
protected override void Dispose(bool disposing)
{
...
}
}
If anyone can give me some tips as how to make this work I would be very
greatful.
Thanks
James
I have recently begun developing an application for PDA's running PocketPC
2003. To break it down, in essance it is a drawing package using vector
graphics. However I have had a real problem trying to get flicker free
drawing to the screen of a PDA (it seems to work fine on the emulator but not
on the actual device).
I understand the basic principle of having a back buffer for drawing to, and
then a front buffer (sorry if the terminology is wrong, I am new to all this)
which you then update to the back buffer when everything is drawn. The way I
do this is as follows:
public class Device : Control
{
...
private System.Drawing.Bitmap back;
...
private System.Windows.Forms.Timer timer;
...
public Device(int width, int height, Control owner)
{
....
this.timer = new Timer();
this.timer.Interval = 33;
this.timer.Enabled = true;
this.back = new Bitmap(width, height);
...
this.timer.Tick +=new EventHandler(timer_Tick);
}
protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.DrawImage(this.back,0,0);
}
public void BeginScene()
{
...
}
public void EndScene()
{
...
}
public void AddPrimitive(IDrawable primitive)
{
....
}
private void timer_Tick(object sender, EventArgs e)
{
if(this.updated)
{
this.Invalidate();
}
}
protected override void Dispose(bool disposing)
{
...
}
}
If anyone can give me some tips as how to make this work I would be very
greatful.
Thanks
James