OpenNB's picture

[Resolved] Using QuickFont with OpenGLControl problem

I'm not sure if this problem is due to the usage of QuickFont with OpenGLControl instead of GameWindow or due to my code, I'm quite new to OpenGL and OpenTK and still in the process of figuring them out..

Whenever I use QuickFont to print text, everything else after that vanishes or is faded out.
Here is the code I'm using, it's in the paint event of the GLControl. Whenever repaint occurs the line disappears but text is still visible

            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
 
            QFont qf = new QFont("LSANS.TTF", 6.0f);
            qf.Options.Colour = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
 
// Draw Diagonal line
            GL.PushMatrix();
            GL.Color3(155, 155, 155);
            GL.Begin(BeginMode.Lines);
            GL.Vertex2(0, 0);
            GL.Vertex2(1, 1);
            GL.End();
            GL.PopMatrix();
 
// Print Quickfont text
            GL.PushMatrix();
            QFont.Begin();
            GL.PushMatrix();
            GL.Translate(Width * 0.1, Height * 0.1, 0);
            qf.Print("Test 1", QFontAlignment.Centre);
            GL.PopMatrix();
            QFont.End();
            GL.PopMatrix();
 
            glControl1.SwapBuffers();

Comments

Comment viewing options

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

After experimenting a bit more, I realised that I was missing the statement

GL.Disable(EnableCap.Texture2D);

which had to be added after the text was added or before the other stuff was rendered and that did the trick