Ejemplo n.º 1
0
        private void UIRenderersDraw(RenderEventArgs arg)
        {
            GLControl uiRoot = this.uiRoot;

            if (uiRoot != null)
            {
                uiRoot.Layout();
                mat4 projection, view, model;
                {
                    projection = glText.GetOrthoProjection();
                    //vec3 position = (this.camera.Position - this.camera.Target).normalize();
                    view = glm.lookAt(new vec3(0, 0, 1), new vec3(0, 0, 0), new vec3(0, 1, 0));
                    //float length = Math.Max(glText.Size.Width, glText.Size.Height) / 2;
                    float length = glText.Size.Height / 2;
                    model = glm.scale(mat4.identity(), new vec3(length, length, length));
                    //model = mat4.identity();
                    glText.Renderer.SetUniform("mvp", projection * view * model);

                    glText.Render(arg);
                }
                {
                    projection = glAxis.GetOrthoProjection();
                    vec3 position = (this.camera.Position - this.camera.Target).normalize();
                    view = glm.lookAt(position, new vec3(0, 0, 0), camera.UpVector);
                    float length = Math.Max(glAxis.Size.Width, glAxis.Size.Height) / 2;
                    model = glm.scale(mat4.identity(),
                                      new vec3(length, length, length));
                    glAxis.Renderer.SetUniform("projectionMatrix", projection);
                    glAxis.Renderer.SetUniform("viewMatrix", view);
                    glAxis.Renderer.SetUniform("modelMatrix", model);

                    glAxis.Render(arg);
                }
            }
        }
Ejemplo n.º 2
0
        private void glCanvas1_OpenGLDraw(object sender, PaintEventArgs e)
        {
            OpenGL.Clear(OpenGL.GL_COLOR_BUFFER_BIT | OpenGL.GL_DEPTH_BUFFER_BIT | OpenGL.GL_STENCIL_BUFFER_BIT);

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

            {
                mat4 projectionMatrix = arg.Camera.GetProjectionMat4();
                mat4 viewMatrix       = arg.Camera.GetViewMat4();
                mat4 modelMatrix      = mat4.identity();
                this.simplexNoiseRenderer.SetUniform("projectionMatrix", projectionMatrix);
                this.simplexNoiseRenderer.SetUniform("viewMatrix", viewMatrix);
                this.simplexNoiseRenderer.SetUniform("modelMatrix", modelMatrix);
                this.simplexNoiseRenderer.Render(arg);
            }
            GLControl uiRoot = this.uiRoot;

            if (uiRoot != null)
            {
                uiRoot.Layout();
                mat4 projection, view, model;
                projection = glAxis.GetOrthoProjection();
                vec3 position = (this.camera.Position - this.camera.Target).normalize();
                view = glm.lookAt(position, new vec3(0, 0, 0), camera.UpVector);
                float length = Math.Max(glAxis.Size.Width, glAxis.Size.Height) / 2;
                model = glm.scale(mat4.identity(),
                                  new vec3(length, length, length));
                glAxis.Renderer.SetUniform("projectionMatrix", projection);
                glAxis.Renderer.SetUniform("viewMatrix", view);
                glAxis.Renderer.SetUniform("modelMatrix", model);

                glAxis.Render(arg);
            }
        }