rounder8's picture

Approach for partial redrawing on 2D environment

Hi, I've got a trading program that uses 2D drawing only. I made my first implementation with GDI+ but ran into performance problems. This is a sample of the graphics (made with GDI+) during slow market activity. When market starts acting quickly GDI implementation gets too slow.

I started to implement the drawing with OpenGL in order to make it faster. How should I approach updating only parts of the screen that are actually changed instead of redrawing everything? How do I keep front and back buffers synched when using double buffering (default in OpenTK)? Right now I'm ending up with situation where one buffer is showing a part of the whole picture and the other buffer the another part of the picture which causes flickering and confusion.


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rounder8's picture

Hmm I think the previous post must have been posted on a wrong thread. Anyway I figured out a solution that seems quick enough for now.

Every time something new is painted (after backbuffer is swapped to front) I just copy everything from current frontbuffer to backbuffer like this:

public void SwapAndCopyBuffers()
            GL.CopyPixels(0, 0, Width, Height, PixelCopyType.Color);

Updating the whole screen even hundreds of times a second with multiple instruments causes no problems at all with this method. Considering I can optimize the code by updating only the neccessary parts this will be extremely fast method.