nileshbukelia's picture

On mouse move drawn text flickering.

Project:The Open Toolkit library
Category:support request
Status:by design

TextPrinter printer = new TextPrinter();
GL.Color3(0.0f, 0.0f, 1.0f);
//change text position as mouse move
GL.Translate(x1,y1, 1);
GL.Rotate(angle, 0, 0, -1);
printer.Draw(text, font);
GL.Color3(1.0f, 1.0f, 1.0f);

I have used this above code for draw a 2D text, its working fine.
When i first click on the screen means thats the start position of the Text
and afterwords i moved the mouse for the text end position means that is the font size.
So now when i moved mouse after first click the drawn text is flickering ,
can anyone help me whats the problem in this code?


Comment viewing options

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


Assigned to:nileshbukelia» Anonymous
the Fiddler's picture


Category:task» support request
Priority:critical» normal

The crux of this issue is double-buffering: OpenGL contexts have two (or more) buffers. The one currently visible on screen is called the "front" buffer and the others called the "back" buffers. All OpenGL rendering commands target the current back buffer by default and calling SwapBuffers swaps the front and back buffers, presenting the results of your rendering to the user.

Drawing on MouseMove means the text will only appear on one of the buffers, making it flicker when you swap. The solution is to place all rendering commands in the RenderFrame (GameWindow) or the Paint (GLControl) events, i.e. redraw everything each frame.

In this case, for example, you could set the text position during the MouseMove event and use it to translate & draw the text during the Paint event.

the Fiddler's picture


Status:open» by design

Please reopen if this problem persists.