private void glWrite(int x, int y, string text) { // Get the OpenGL object. OpenGL gl = openGLControl.OpenGL; char[] temp = new char[text.Length]; for (int i = 0; i < text.Length; i++) { temp[i] = text[i]; } Marshal.Copy(temp, 0, ptr1, temp.Length); gl.PushAttrib(OpenGL.GL_DEPTH_TEST); // Save the current Depth test settings (Used for blending ) gl.Disable(OpenGL.GL_DEPTH_TEST); // Turn off depth testing (otherwise we get no FPS) gl.Disable(OpenGL.GL_TEXTURE_2D); // Turn off textures, don't want our text textured gl.MatrixMode(OpenGL.GL_PROJECTION); // Switch to the projection matrix gl.PushMatrix(); // Save current projection matrix gl.LoadIdentity(); gl.Ortho(0, 640, 0, 429, -1, 1); // Change the projection matrix using an orthgraphic projection gl.MatrixMode(OpenGL.GL_MODELVIEW); // Return to the modelview matrix gl.PushMatrix(); // Save the current modelview matrix gl.LoadIdentity(); gl.Color(1.0, 1.0, 1.0); // Text color gl.RasterPos(x, y); // Position the Text gl.PushAttrib(OpenGL.GL_LIST_BIT); // Save's the current base list gl.ListBase(based + 2); // Set the base list to our character list gl.CallLists(text.Length, OpenGL.GL_UNSIGNED_BYTE, ptr1); // Display the text gl.PopAttrib(); // Restore the old base list gl.MatrixMode(OpenGL.GL_PROJECTION); //Switch to projection matrix gl.PopMatrix(); // Restore the old projection matrix gl.MatrixMode(OpenGL.GL_MODELVIEW); // Return to modelview matrix gl.PopMatrix(); // Restore old modelview matrix gl.Enable(OpenGL.GL_TEXTURE_2D); // Turn on textures, don't want our text textured gl.PopAttrib(); // Restore depth testing }
public void glCallListsByte(int n, byte[] lists) { gl.CallLists(n, lists); }