Exemplo n.º 1
0
        void OpenGLDraw()
        {
            bool blend, depthTest;

            GL.GetBoolean(GetPName.Blend, out blend);
            GL.GetBoolean(GetPName.DepthTest, out depthTest);
            GL.Enable(EnableCap.Blend);
            GL.Disable(EnableCap.DepthTest);

            shader.Enable();
            shader.SetMVP(projection);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, texID);
            lock (CrowInterface.RenderMutex) {
                if (CrowInterface.IsDirty)
                {
                    GL.TexSubImage2D(TextureTarget.Texture2D, 0,
                                     CrowInterface.DirtyRect.Left, CrowInterface.DirtyRect.Top,
                                     CrowInterface.DirtyRect.Width, CrowInterface.DirtyRect.Height,
                                     OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, CrowInterface.dirtyBmp);
                    CrowInterface.IsDirty = false;
                }
            }
            quad.Render(BeginMode.TriangleStrip);
            GL.BindTexture(TextureTarget.Texture2D, 0);

            if (!blend)
            {
                GL.Disable(EnableCap.Blend);
            }
            if (depthTest)
            {
                GL.Enable(EnableCap.DepthTest);
            }
        }
Exemplo n.º 2
0
        void openGLDraw()
        {
            //save GL states
            bool blend, depthTest, cullFace;

            GL.GetBoolean(GetPName.Blend, out blend);
            GL.GetBoolean(GetPName.DepthTest, out depthTest);
            GL.GetBoolean(GetPName.CullFace, out cullFace);
            GL.Enable(EnableCap.Blend);
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);

                        #if MEASURE_TIME
            glDrawMeasure.StartCycle();
                        #endif

            shader.Enable();
            for (int i = 0; i < ifaceControl.Count; i++)
            {
                shader.SetMVP(ifaceControl [i].InterfaceMVP);
                ifaceControl [i].OpenGLDraw();
            }

                        #if MEASURE_TIME
            glDrawMeasure.StopCycle();
                        #endif

            //restore GL states
            if (!blend)
            {
                GL.Disable(EnableCap.Blend);
            }
            if (depthTest)
            {
                GL.Enable(EnableCap.DepthTest);
            }
            if (cullFace)
            {
                GL.Enable(EnableCap.CullFace);
            }
        }