APXEOLOG's picture

TextPrinter help

I'm trying to print some text with such code:

OpenTK.Graphics.TextPrinter printer = new OpenTK.Graphics.TextPrinter(OpenTK.Graphics.TextQuality.Medium);
Font font = new Font("Times New Roman", 10.0f);
 
protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 
            Matrix4 lookat = Matrix4.LookAt(x, 300, y + 25.0f, x, 0, y, 0, 1, 0);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadMatrix(ref lookat);
 
....
 
             SwapBuffers();
 
            printer.Begin();
            printer.Print("test", font, Color.Black);//, new RectangleF(1.0f, 1.0f, 10.0f, 10.0f));
            printer.End();
 
        }

But i have no text on screen =(
Any ideas whats i'm doing wrong?


Comments

Comment viewing options

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

Your code above is essentially equivalent to this:

while (true)
{
    GL.Clear(...);
    ...
    SwapBuffers();
    printer.Print(...);
}

In other words, you perform the buffer swap, print the text to the back buffer and then immediately clear the back buffer. Your text never reaches the front buffer (i.e. screen).

You need to move printer.[Begin|Print|End] above the SwapBuffers() call.

APXEOLOG's picture

omg... thank you!