public static void Configure(OpenTK.GLControl refGLControl, Ortho_Mode ortho) { GL.ClearColor(Color.DimGray); refGLControl.VSync = false; GL.Clear(ClearBufferMask.ColorBufferBit); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(Color.DimGray); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.Viewport(refGLControl.Size); if (ortho == Ortho_Mode.CENTER) { GL.Ortho(-refGLControl.Width / 2, refGLControl.Width / 2, -refGLControl.Height / 2, refGLControl.Height / 2, -20000, +20000); } else { GL.Ortho(0, refGLControl.Width, 0, refGLControl.Height, -20000, +20000); } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.ClearDepth(1.0f); GL.Enable(EnableCap.DepthTest); GL.DepthFunc(DepthFunction.Lequal); GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest); GL.Enable(EnableCap.LineSmooth); GL.Hint(HintTarget.LineSmoothHint, HintMode.Nicest); GL.Enable(EnableCap.PolygonSmooth); GL.Hint(HintTarget.PolygonSmoothHint, HintMode.Nicest); }
/** * @brief Bu fonksiyon, OpenGL ekraninin koordinat duzlemini (ortho) ve pencerenin * ne kadarinda goruntunun gosterilecegini (viewport) ayarlar. Aynı zamanda * OpenGL ekranininin derinlik ve renk buffer'ini temizler * @param glMonitor * @retval yok */ public void glInit(SimpleOpenGlControl glMonitor, Ortho_Mode mode) { Gl.glClearColor(0, 0, 0, 0); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); Gl.glViewport(0, 0, glMonitor.Width, glMonitor.Height); // Görüntülenecek alan tanımlanıyor ve pencere boyutunun değişme durumuna göre open gl penceresinin parametreleri ayarlanıyor if (mode == Ortho_Mode.BLEFT) { Gl.glOrtho(0, glMonitor.Width, 0, glMonitor.Height, 4000, -4000); // Orijin tanımlanıyor } else if (mode == Ortho_Mode.CENTER) { Gl.glOrtho(-glMonitor.Width / 2, glMonitor.Width / 2, -glMonitor.Height / 2, glMonitor.Height / 2, 4000, -4000); // Orijin tanımlanıyor } else if (mode == Ortho_Mode.CLEFT) { Gl.glOrtho(0, glMonitor.Width, -glMonitor.Height / 2, glMonitor.Height / 2, 4000, -4000); // Orijin tanımlanıyor } else { // bilerek bos birakildi } Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT); Gl.glClearDepth(1.0f); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LEQUAL); Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); }