开发者

C# Double Buffering?

I am using the COSMOS compiler to write an OS in C# (For those who dont know COSMOS converts IL code into x86 assembly) and I am making a GUI.

I have made GUIs before but now i am trying to make a double b开发者_运维百科uffer.

It sounds rather easy but following is my problem -

I cant use any methods from the System.Drawing Library or any other namespace that uses p/ invokes. Also, I can not use multi Dimensional arrays (I CAN use regular arrays). So my question is how would I implement double buffer?

I know it is possible because I know someone who did it.

Additionally, the only graphical functions I have are SetPixel , GetPixel and Clear. All though I prefer an answer , if any one knows a good article about double buffering ect please tell me.

PS. My OS in 320 x 200 Res LOL


You will need to learn a little bit of DOS C VGA game lore it sounds like ;-)

See Double Buffering, Page Flipping, & Unchained Mode. All the same concepts apply, not sure how they will translate to the C# code though.

Happy coding.


Try to see if you can access System.Drawing.BufferedGraphics. It implements methods for that purpose. Otherwise, I'm afraid you have to do it manually.

Usually, when you draw directly on the screen, the user sees what you’re drawing as it’s being drawn. It’s like when you ask Alex to draw you an apple; you’ll examine him while he draws the apple with the pen. Now if you ask Alex to draw a red apple, then erase it, then draw a blue apple, then erase it then draw a yellow apple, etc… You’ll be looking at him while he’s erasing it each time. Think of it this way: The computer is a fast Alex. So if you ask for a fast animation to be drawn directly on the screen, the user will mark that something is happening between the animation frames: bad flickering!

The solution to flickering is double buffering. A buffer is simply an off-screen area of memory used for drawing. When you use double buffering, instead of drawing directly to the screen, you draw to a back buffer, located in the video memory, and then copy the entire buffer to the screen.


Double buffering can be implemented by using an array to plot to (as opposed to the display) and by blitting the array (when finished plotting) to the display.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜