private void StartGlIfNecessary() { if (!m_isStarted) { try { // Attempt To Get A Device Context m_hdc = User.GetDC(Handle); if (m_hdc == IntPtr.Zero) { throw new InvalidOperationException("Can't get device context"); } OpenGlCore.InitOpenGl(m_hdc, out m_hglrc); Initialize(); m_isStarted = true; } catch (Exception ex) { StopGl(false); Outputs.WriteLine(OutputMessageType.Error, ex.Message); Outputs.WriteLine(OutputMessageType.Info, ex.StackTrace); } } }
private void StopGl(bool disposing) { Shutdown(); OpenGlCore.ShutdownOpenGl(ref m_hglrc); if (disposing && (m_hdc != IntPtr.Zero)) { User.ReleaseDC(Handle, m_hdc); m_hdc = IntPtr.Zero; } m_isStarted = false; }
/// <summary> /// Draws a string at given 2D coordinates</summary> /// <param name="text">Text</param> /// <param name="x">X coordinate</param> /// <param name="y">Y coordinate</param> public static void DrawText(string text, int x, int y) { Gl.glRasterPos2i(x, y); OpenGlCore.DrawText(text); }