コード例 #1
0
        void element_BeforeRendering(object sender, Objects.RenderEventArgs e)
        {
            var       element = sender as FontElement;
            Texture2D texture = element.texture;

            texture.Bind();

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

            ShaderProgram shaderProgram = element.shaderProgram;

            shaderProgram.Bind();

            shaderProgram.SetUniform(FontElement.strcolor, 1.0f, 1.0f, 1.0f, 1.0f);
            shaderProgram.SetUniform(FontElement.strtex, texture.Name);

            mat4 projectionMatrix = this.camera.GetProjectionMat4();
            mat4 viewMatrix       = this.camera.GetViewMat4();
            mat4 modelMatrix      = mat4.identity();
            IMVP iMVP             = sender as IMVP;

            iMVP.SetShaderProgram(projectionMatrix * viewMatrix * modelMatrix);
        }
コード例 #2
0
        static void IMVPElement_BeforeRendering(object sender, RenderEventArgs e)
        {
            // 三维场景中所有的元素都应在Camera的照耀下现形,没有Camera就不知道元素该放哪儿。
            // UI元素不在三维场景中,所以其Camera可以是null。
            if (e.Camera == null)
            {
                throw new ArgumentNullException();
                //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 projectionMatrix, viewMatrix;

            viewMatrix       = e.Camera.GetViewMat4();
            projectionMatrix = e.Camera.GetProjectionMat4();

            mat4 mvp = projectionMatrix * viewMatrix * modelMatrix;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(projectionMatrix * viewMatrix * modelMatrix);
        }
コード例 #3
0
        void element_BeforeRendering(object sender, Objects.RenderEventArgs 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;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(mvp);
        }
コード例 #4
0
        static void SimpleUI_BeforeRendering(object sender, RenderEventArgs e)
        {
            mat4 projectionMatrix, viewMatrix, modelMatrix;
            {
                IUILayout element = sender as IUILayout;
                element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera);
            }

            {
                IMVP element = sender as IMVP;
                element.SetShaderProgram(projectionMatrix * viewMatrix * modelMatrix);
            }
        }
コード例 #5
0
        void axisElement_BeforeRendering(object sender, 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);
        }
コード例 #6
0
        void pyramidElement_BeforeRendering(object sender, Objects.RenderEventArgs e)
        {
            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;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(mvp);
        }
コード例 #7
0
ファイル: FormSphere.cs プロジェクト: benlanaaa/CSharpGL
        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);
        }
コード例 #8
0
        void pyramidElement_BeforeRendering(object sender, Objects.RenderEventArgs 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;

            IMVP element = sender as IMVP;

            element.SetShaderProgram(mvp);
        }
コード例 #9
0
ファイル: SimpleUIAxis.cs プロジェクト: windygu/CSharpGL
        void IMVP.SetShaderProgram(mat4 mvp)
        {
            IMVP element = this.axisElement as IMVP;

            element.SetShaderProgram(mvp);
        }