Пример #1
0
        //-----------------------------------------------------------------------------------------
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            float currentTime = (float)Program.ElapsedTimeSeconds;

            GL.Viewport(0, 0, Width, Height);
            GL.ClearBuffer(ClearBuffer.Depth, 0, Statics.one);
            GL.ClearBuffer(ClearBuffer.Color, 0, Statics.colorGreen);

            GL.UseProgram(_shaderProgramName);

            Matrix4 projMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(50.0f),
                                                                      Width / Height, 0.1f, 1000.0f);

            GL.UniformMatrix4(_projLocation, false, ref projMatrix);

            Matrix4 mvMatrix = Matrix4.Identity
                               * Matrix4.CreateFromAxisAngle(new Vector3(0.0f, 1.0f, 0.0f),
                                                             MathHelper.DegreesToRadians((float)currentTime * 20.0f))
                               * Matrix4.CreateTranslation(0.0f, -0.5f, -7.0f);

            GL.UniformMatrix4(_mvLocation, false, ref mvMatrix);

            _model.Render();

            SwapBuffers();
        }
Пример #2
0
        //-----------------------------------------------------------------------------------------
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            float currentTime = (float)Program.ElapsedTimeSeconds;

            GL.Viewport(0, 0, Width, Height);
            GL.ClearBuffer(ClearBuffer.Depth, 0, Statics.one);
            GL.ClearBuffer(ClearBuffer.Color, 0, Statics.colorGreen);

            GL.BindTexture(TextureTarget.Texture2D, _textures.Array[_textureIndex]);

            GL.UseProgram(_shaderPrograms.Name);

            Matrix4 projMatrix = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(60.0f),
                                                                      Width / Height, 0.1f, 1000.0f);
            Matrix4 mvMatrix = Matrix4.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f),
                                                           MathHelper.DegreesToRadians((float)currentTime * 21.1f))
                               * Matrix4.CreateFromAxisAngle(new Vector3(0.0f, 1.0f, 0.0f),
                                                             MathHelper.DegreesToRadians((float)currentTime * 19.3f))
                               * Matrix4.CreateTranslation(0.0f, 0.0f, -3.0f);

            GL.UniformMatrix4(_uniforms.ProjLocation, false, ref projMatrix);
            GL.UniformMatrix4(_uniforms.MVLocation, false, ref mvMatrix);

            _model.Render();

            SwapBuffers();
        }