private void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, null);
            pyramidElement.Render(arg);
        }
        protected override void DoRender(RenderEventArgs e)
        {
            mat4 projectionMatrix, viewMatrix, modelMatrix;
            {
                IUILayout element = this as IUILayout;
                element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera);
            }

            this.element.mvp = projectionMatrix * viewMatrix * modelMatrix;

            this.element.Render(e);
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            element.mvp = mvp;

            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            element.Render(arg);
        }
Beispiel #4
0
        void element_BeforeRendering(object sender, CSharpGL.Objects.RenderEventArgs e)
        {
            mat4 projectionMatrix = camera.GetProjectionMat4();

            mat4 viewMatrix = camera.GetViewMat4();

            mat4 modelMatrix = mat4.identity();

            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(mvp);
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            cylinderElement.mvp = mvp;

            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            cylinderElement.Render(arg);
            ////  Load the identity matrix.
            //GL.LoadIdentity();

            ////  Rotate around the Y axis.
            //GL.Rotate(rotation, 0.0f, 1.0f, 0.0f);

            ////  Draw a coloured pyramid.
            //GL.Begin(GL.GL_TRIANGLES);
            //GL.Color(1.0f, 0.0f, 0.0f);
            //GL.Vertex(0.0f, 1.0f, 0.0f);
            //GL.Color(0.0f, 1.0f, 0.0f);
            //GL.Vertex(-1.0f, -1.0f, 1.0f);
            //GL.Color(0.0f, 0.0f, 1.0f);
            //GL.Vertex(1.0f, -1.0f, 1.0f);
            //GL.Color(1.0f, 0.0f, 0.0f);
            //GL.Vertex(0.0f, 1.0f, 0.0f);
            //GL.Color(0.0f, 0.0f, 1.0f);
            //GL.Vertex(1.0f, -1.0f, 1.0f);
            //GL.Color(0.0f, 1.0f, 0.0f);
            //GL.Vertex(1.0f, -1.0f, -1.0f);
            //GL.Color(1.0f, 0.0f, 0.0f);
            //GL.Vertex(0.0f, 1.0f, 0.0f);
            //GL.Color(0.0f, 1.0f, 0.0f);
            //GL.Vertex(1.0f, -1.0f, -1.0f);
            //GL.Color(0.0f, 0.0f, 1.0f);
            //GL.Vertex(-1.0f, -1.0f, -1.0f);
            //GL.Color(1.0f, 0.0f, 0.0f);
            //GL.Vertex(0.0f, 1.0f, 0.0f);
            //GL.Color(0.0f, 0.0f, 1.0f);
            //GL.Vertex(-1.0f, -1.0f, -1.0f);
            //GL.Color(0.0f, 1.0f, 0.0f);
            //GL.Vertex(-1.0f, -1.0f, 1.0f);
            //GL.End();

            ////  Nudge the rotation.
            //rotation += 3.0f;

        }
Beispiel #6
0
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            rotation += 3.0f;
            modelMatrix = glm.rotate(rotation, new vec3(0, 1, 0));
            viewMatrix = this.camera.GetViewMat4();
            projectionMatrix = this.camera.GetProjectionMat4();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            element.mvp = mvp;

            //GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            element.Render(arg);
        }
Beispiel #7
0
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            //GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            this.element.projectionMatrix = projectionMatrix;
            this.element.viewMatrix = viewMatrix;
            this.element.modelMatrix = modelMatrix;

            element.Render(arg);
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            //  Clear the color and depth buffer.
            //GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            projectionMatrix = glm.translate(projectionMatrix, new vec3(translateX, translateY, translateZ));//
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            axisElement.mvp = mvp;

            axisElement.Render(arg);

        }
        private void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            rotation += 3.0f;
            mat4 modelMatrix = glm.rotate(rotation, new vec3(0, 1, 0));
            const float distance = 0.7f;
            viewMatrix = glm.lookAt(new vec3(-distance, distance, -distance), new vec3(0, 0, 0), new vec3(0, -1, 0));
            int[] viewport = new int[4];
            GL.GetInteger(GetTarget.Viewport, viewport);
            projectionMatrix = glm.perspective(60.0f, (float)viewport[2] / (float)viewport[3], 0.01f, 100.0f);
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            pyramidElement.mvp = mvp;

            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, null);
            pyramidElement.Render(arg);
        }
Beispiel #10
0
        /// <summary>
        /// 渲染
        /// </summary>
        /// <param name="renderMode"></param>
        public void Render(RenderEventArgs e)
        {
            if (!initialized) { Initialize(); }

            EventHandler<RenderEventArgs> beforeRendering = this.BeforeRendering;
            if (beforeRendering != null)
            {
                beforeRendering(this, e);
            }

            DoRender(e);

            EventHandler<RenderEventArgs> afterRendering = this.AfterRendering;
            if (afterRendering != null)
            {
                afterRendering(this, e);
            }
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            PrintCameraInfo();

            //GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            axisElement.mvp = mvp;

            axisElement.Render(arg);

            var uiArg = new RenderEventArgs(RenderModes.Render, null);

            uiRectElement.Render(uiArg);
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            mat4 projectionMatrix = camera.GetProjectionMat4();
            mat4 viewMatrix = camera.GetViewMat4();
            mat4 modelMatrix = mat4.identity();
            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            switch (this.renderOrder)
            {
                case RenderOrder.Increase:
                    element.mvp = mvp;

                    element.Render(arg);
                    break;
                case RenderOrder.Decrease:
                    elementReversed.mvp = mvp;

                    elementReversed.Render(arg);
                    break;
                case RenderOrder.IncreaseThenDecrease:
                    element.mvp = mvp;
                    elementReversed.mvp = mvp;

                    element.Render(arg);
                    elementReversed.Render(arg);
                    break;
                case RenderOrder.DecreaseThenIncrease:
                    elementReversed.mvp = mvp;
                    element.mvp = mvp;

                    elementReversed.Render(arg);
                    element.Render(arg);
                    break;
                default:
                    throw new NotImplementedException();
            }
        }
Beispiel #13
0
        /// <summary>
        /// Render the element that inherts <see cref="IColorCodedPicking"/> for color coded picking.
        /// </summary>
        /// <param name="pickable"></param>
        /// <param name="gl"></param>
        /// <param name="renderMode"></param>
        public virtual void RenderForPicking(IColorCodedPicking pickable, RenderEventArgs e)
        {
            if (pickable != null)
            {
                pickable.PickingBaseID = this.RenderedVertexCount;

                //  render the element.
                IRenderable renderable = pickable;
                renderable.Render(e);

                uint rendered = this.RenderedVertexCount + pickable.GetVertexCount();
                if (this.RenderedVertexCount <= rendered)
                {
                    this.RenderedVertexCount = rendered;
                }
                else
                {
                    throw new OverflowException(
                        string.Format("Too many geometries({0} + {1} > {2}) for color coded picking.",
                            this.RenderedVertexCount, pickable.GetVertexCount(), uint.MaxValue));
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// 渲染
        /// </summary>
        /// <param name="renderMode"></param>
        public void Render(RenderEventArgs e)
        {
            if (!initialized) { Initialize(); }

            DoRender(e);
        }
Beispiel #15
0
        protected override void DoRender(RenderEventArgs e)
        {
            if (this.axisVAO == null)
            {
                this.axisVAO = new VertexArrayObject[3];
                for (int i = 0; i < 3; i++)
                {
                    var vao = new VertexArrayObject(this.positionBufferRenderers[i], this.colorBufferRenderers[i], this.indexBufferRenderers[i]);
                    vao.Create(e, this.shaderProgram);

                    this.axisVAO[i] = vao;
                }

                {
                    var vao = new VertexArrayObject(this.planPositionBufferRenderer, planColorBufferRenderer, this.planIndexBufferRenderer);
                    vao.Create(e, this.shaderProgram);

                    this.planVAO = vao;
                }
            }

            // 绑定shader
            this.shaderProgram.Bind();

            // 画坐标轴
            for (int i = 0; i < 3; i++)
            {
                this.axisVAO[i].Render(e, this.shaderProgram);
            }
            // 画平面
            {
                this.planVAO.Render(e, this.shaderProgram);
            }

            // 解绑shader
            this.shaderProgram.Unbind();
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            PrintCameraInfo();

            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            axisElement.Render(arg);

            var uiArg = new RenderEventArgs(RenderModes.Render, null);
            uiRectElement.Render(uiArg);
        }
Beispiel #17
0
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            PrintCameraInfo();

            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);

            sphereElement.Render(arg);
            lightElement.Render(arg);

            uiLeftBottomAxis.Render(arg);
            //uiLeftTopAxis.Render(arg);
            //uiRightBottomAxis.Render(arg);
            //uiRightTopAxis.Render(arg);

            //uiLeftBottomRect.Render(arg);
            //uiLeftTopRect.Render(arg);
            //uiRightBottomRect.Render(arg);
            //uiRightTopRect.Render(arg);
        }
Beispiel #18
0
        void pointLightElement_BeforeRendering(object sender, RenderEventArgs e)
        {
            mat4 projectionMatrix = camera.GetProjectionMat4();
            projectionMatrix = glm.translate(projectionMatrix, new vec3(translateX, translateY, translateZ));//
            //projectionMatrix = glm.scale(projectionMatrix, new vec3(0.1f, 0.1f, 0.1f));

            mat4 viewMatrix = camera.GetViewMat4();

            mat4 modelMatrix = glm.scale(mat4.identity(), new vec3(0.1f, 0.1f, 0.1f));

            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(mvp);
        }
        //private void glCanvas1_MouseClick(object sender, MouseEventArgs e)
        //{
        //    if (e.Button == System.Windows.Forms.MouseButtons.Right)
        //    {
        //        IPickedGeometry pickedGeometry = this.Pick(e.X, e.Y);
        //        if (pickedGeometry != null)
        //        {
        //            this.txtPickedInfo.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss.ff} {1}",
        //                DateTime.Now, pickedGeometry);
        //        }
        //        else
        //        {
        //            this.txtPickedInfo.Text = string.Format("{0:yyyy-MM-dd HH:mm:ss.ff} {1}",
        //                DateTime.Now, "nothing picked");
        //        }
        //    }
        //}

        private IPickedGeometry Pick(int x, int y)
        {
            //this.glCanvas1.MakeCurrent();
            // render the scene for color-coded picking.
            GL.ClearColor(1.0f, 1.0f, 1.0f, 1.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            SharedStageInfo info = new SharedStageInfo();
            info.Reset();
            var arg = new RenderEventArgs(RenderModes.HitTest, this.camera);

            IColorCodedPicking pickable = this.element;
            info.RenderForPicking(pickable, arg);

            GL.Flush();

            // get coded color.
            //byte[] codedColor = new byte[4];
            UnmanagedArray<byte> codedColor = new UnmanagedArray<byte>(4);
            GL.ReadPixels(x, this.glCanvas1.Height - y - 1, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, codedColor.Header);
            if (codedColor[0] == byte.MaxValue && codedColor[1] == byte.MaxValue
                && codedColor[2] == byte.MaxValue && codedColor[3] == byte.MaxValue)
            {
                // This is when (x, y) is on background and no primitive is picked.
                return null;
            }

            /* // This is how is vertexID coded into color in vertex shader.
             * 	int objectID = gl_VertexID;
                codedColor = vec4(
                    float(objectID & 0xFF), 
                    float((objectID >> 8) & 0xFF), 
                    float((objectID >> 16) & 0xFF), 
                    float((objectID >> 24) & 0xFF));
             */

            // get vertexID from coded color.
            // the vertexID is the last vertex that constructs the primitive.
            // see http://www.cnblogs.com/bitzhuwei/p/modern-opengl-picking-primitive-in-VBO-2.html
            uint shiftedR = (uint)codedColor[0];
            uint shiftedG = (uint)codedColor[1] << 8;
            uint shiftedB = (uint)codedColor[2] << 16;
            uint shiftedA = (uint)codedColor[3] << 24;
            uint stageVertexID = shiftedR + shiftedG + shiftedB + shiftedA;

            // get picked primitive.
            IPickedGeometry pickedGeometry = null;
            pickedGeometry = ((IColorCodedPicking)this.element).Pick(stageVertexID);

            return pickedGeometry;
        }
Beispiel #20
0
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            PrintCameraInfo();

            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            axisElement.Render(arg);

            var uiArg = new RenderEventArgs(RenderModes.Render, null);
            if (this.renderSign % 2 == 0)
            {
                uiLeftBottomRect.Render(uiArg);
                uiLeftTopRect.Render(uiArg);
                uiRightBottomRect.Render(uiArg);
                uiRightTopRect.Render(uiArg);
            }
            else if (this.renderSign % 2 == 1)
            {
                legacyLeftBottomRect.Render(uiArg);
                legacyLeftTopRect.Render(uiArg);
                legacyRightBottomRect.Render(uiArg);
                legacyRightTopRect.Render(uiArg);
            }
        }
Beispiel #21
0
        protected override void DoRender(RenderEventArgs e)
        {
            GL.BindVertexArray(vao[0]);

            //GL.DrawArrays(primitiveMode, 0, vertexCount);
            GL.DrawElements(primitiveMode, faceCount * 2 + 2, GL.GL_UNSIGNED_INT, IntPtr.Zero);

            GL.BindVertexArray(0);
        }
        protected override void OnPaint(PaintEventArgs e)
        {
            RenderContext renderContext = this.renderContext;
            if (renderContext != null)
            {
                Graphics graphics = e.Graphics;

                //	Make sure it's our instance of openSharpGL that's active.
                renderContext.MakeCurrent();

                if (this.designMode)
                {
                    // 天蓝色背景
                    GL.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);

                    GLCanvasHelper.ResizeGL(this.Width, this.Height);

                    GLCanvasHelper.DrawPyramid();

                }
                else
                {
                    GL.ClearColor(clearColor.x, clearColor.y, clearColor.z, clearColor.w);
                    GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

                    var arg = new RenderEventArgs(RenderModes.Render, this.camera);
                    //	If there is a draw handler, then call it.
                    //DoOpenGLDraw(new RenderEventArgs(graphics));
                    foreach (var item in this.elementList)
                    {
                        item.Render(arg);
                    }
                }

                //	Blit our offscreen bitmap.
                var handleDeviceContext = graphics.GetHdc();
                renderContext.Blit(handleDeviceContext);
                graphics.ReleaseHdc(handleDeviceContext);
            }
            else
            {
                base.OnPaint(e);
            }
        }
Beispiel #23
0
        protected override void DoRender(RenderEventArgs e)
        {
            GL.BindVertexArray(vao[0]);

            GL.DrawArrays(primitiveMode, 0, vertexCount);

            GL.BindVertexArray(0);
        }
 protected override void DoRender(RenderEventArgs e)
 {
     this.element.Render(e);
 }
Beispiel #25
0
        protected override void DoRender(RenderEventArgs e)
        {
            

            ShaderProgram program = this.shaderProgram;
            // 绑定shader
            program.Bind();

            program.SetUniformMatrix4(strprojectionMatrix, projectionMatrix.to_array());
            program.SetUniformMatrix4(strviewMatrix, viewMatrix.to_array());
            program.SetUniformMatrix4(strmodelMatrix, modelMatrix.to_array());

            int[] originalPolygonMode = new int[1];
            GL.GetInteger(GetTarget.PolygonMode, originalPolygonMode);

            GL.PolygonMode(PolygonModeFaces.FrontAndBack, this.polygonMode);
            if (this.vertexArrayObject == null)
            {
                var vao = new VertexArrayObject(
                    this.positionBufferRenderer,
                    //this.colorBufferRenderer,
                    this.normalBufferRenderer,
                    this.indexBufferRenderer);
                vao.Create(e, this.shaderProgram);

                this.vertexArrayObject = vao;
            }
            else
            {
                this.vertexArrayObject.Render(e, this.shaderProgram);
            }
            GL.PolygonMode(PolygonModeFaces.FrontAndBack, (PolygonModes)(originalPolygonMode[0]));

            // 解绑shader
            program.Unbind();
        }
Beispiel #26
0
        void element_AfterRendering(object sender, CSharpGL.Objects.RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }
        private void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, null);

            this.uiAxis.Render(arg);

            DoRender(sender, e);
        }
Beispiel #28
0
        static void IMVPElement_AfterRendering(object sender, RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }
        protected override void DoRender(RenderEventArgs e)
        {
            CSharpGL.Objects.Texture2D texture = this.texture;
            texture.Bind();

            if (this.blend)
            {
                GL.Enable(GL.GL_BLEND);
                GL.BlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
            }

            ShaderProgram shaderProgram = this.shaderProgram;
            shaderProgram.Bind();
            GL.ActiveTexture(GL.GL_TEXTURE0);
            GL.Enable(GL.GL_TEXTURE_2D);
            texture.Bind();
            shaderProgram.SetUniform(strtex, 0);
            shaderProgram.SetUniform(WholeFontTextureElement.strcolor, 1.0f, 1.0f, 1.0f, 1.0f);
            shaderProgram.SetUniformMatrix4("MVP", (projectionMatrix * viewMatrix * modelMatrix).to_array());

            GL.BindVertexArray(vao[0]);
            GL.DrawArrays(this.mode, 0, this.vertexCount);
            GL.BindVertexArray(0);

            texture.Unbind();
            shaderProgram.Unbind();

            GL.BindTexture(GL.GL_TEXTURE_2D, 0);

            if (this.blend)
            {
                GL.Disable(GL.GL_BLEND);
            }
        }
        void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            //PrintCameraInfo();

            GL.ClearColor(0x87 / 255.0f, 0xce / 255.0f, 0xeb / 255.0f, 0xff / 255.0f);
            GL.Clear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

            var arg = new RenderEventArgs(RenderModes.Render, this.camera);
            legacyUIRect_BeforeRendering(this.legacyUIRect, arg);
            legacyUIRect.Render(arg);
            legacyUIRect_AfterRendering(this.legacyUIRect, arg);
            modernUIRect.Render(arg);
            leftUIAxis.Render(arg);
            rightUIAxis.Render(arg);
            element_BeforeRendering(this.element, arg);
            element.Render(arg);
            element_AfterRendering(this.element, arg);
        }
Beispiel #31
0
        protected override void DoRender(RenderEventArgs e)
        {
            this.shaderProgram.Bind();
            this.shaderProgram.SetUniformMatrix4(strMVP, mvp.to_array());

            GL.BindVertexArray(vao[0]);

            GL.DrawArrays(primitiveMode, 0, vertexCount);

            GL.BindVertexArray(0);

            this.shaderProgram.Unbind();
        }
Beispiel #32
0
 /// <summary>
 /// 执行渲染操作
 /// </summary>
 /// <param name="renderMode"></param>
 protected abstract void DoRender(RenderEventArgs e);
Beispiel #33
0
        void pointLightElement_AfterRendering(object sender, RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }