
On mouse move drawn text flickering.
Posted Tuesday, 3 February, 2009 - 09:57 by nileshbukelia| Project: | The Open Toolkit library |
| Version: | 0.9.1 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | by design |
Jump to:
Description
TextPrinter printer = new TextPrinter();
GL.Color3(0.0f, 0.0f, 1.0f);
printer.Begin();
//change text position as mouse move
GL.Translate(x1,y1, 1);
GL.Rotate(angle, 0, 0, -1);
printer.Draw(text, font);
printer.End();
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?


Comments
#1
#2
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.
#3
Please reopen if this problem persists.