Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        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;

        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 8
0
        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);

        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 11
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);
            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);
        }
Ejemplo n.º 12
0
        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();
            }
        }
Ejemplo n.º 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));
                }
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 渲染
        /// </summary>
        /// <param name="renderMode"></param>
        public void Render(RenderEventArgs e)
        {
            if (!initialized) { Initialize(); }

            DoRender(e);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 16
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);
            uiRectElement.Render(uiArg);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 19
0
        //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;
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 22
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);
            }
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 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();
        }
Ejemplo n.º 26
0
        void element_AfterRendering(object sender, CSharpGL.Objects.RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }
Ejemplo n.º 27
0
        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);
        }
Ejemplo n.º 28
0
        static void IMVPElement_AfterRendering(object sender, RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }
Ejemplo n.º 29
0
        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);
            }
        }
Ejemplo n.º 30
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);
            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);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 32
0
 /// <summary>
 /// 执行渲染操作
 /// </summary>
 /// <param name="renderMode"></param>
 protected abstract void DoRender(RenderEventArgs e);
Ejemplo n.º 33
0
        void pointLightElement_AfterRendering(object sender, RenderEventArgs e)
        {
            IMVP element = sender as IMVP;

            element.ResetShaderProgram();
        }