public static void DrawString(int x, int y, string str) { if (sIsTextRendererInitialized) { GL.MatrixMode(MatrixMode.Projection); GL.PushMatrix(); GL.LoadIdentity(); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.LoadIdentity(); float xOffset = -0.95f + (float)x / ((float)openGlControl.Width / 2f); float yOffset = 0.95f - (float)y / ((float)openGlControl.Height / 2f); // Offset the font on the screen GL.Translate(xOffset, yOffset, 0); GL.Color3(0.9f, 0.6f, 0.6f); // Scale the font GL.Scale(0.0035f, 0.0035f, 0.0035f); // Begin writing the font sysfont.ftBeginFont(); sysfont.ftWrite(str); // Stop writing the font and restore old OpenGL parameters sysfont.ftEndFont(); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Projection); GL.PopMatrix(); GL.MatrixMode(MatrixMode.Modelview); } }
public static void DrawString(int x, int y, string str) { if (sIsTextRendererInitialized) { Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPushMatrix(); Gl.glLoadIdentity(); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glPushMatrix(); Gl.glLoadIdentity(); float xOffset = -0.95f + (float)x / ((float)openGlControl.Width / 2f); float yOffset = 0.95f - (float)y / ((float)openGlControl.Height / 2f); // Offset the font on the screen Gl.glTranslatef(xOffset, yOffset, 0); Gl.glColor3f(0.9f, 0.6f, 0.6f); // Scale the font Gl.glScalef(0.0035f, 0.0035f, 0.0035f); // Begin writing the font sysfont.ftBeginFont(); sysfont.ftWrite(str); // Stop writing the font and restore old OpenGL parameters sysfont.ftEndFont(); Gl.glPopMatrix(); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPopMatrix(); Gl.glMatrixMode(Gl.GL_MODELVIEW); } }