Exemple #1
0
        protected override void Render()
        {
            glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            glClear(GL_COLOR_BUFFER_BIT);

            Vector2 camPosition = new Vector2(300, 300);
            Vector2 camScale    = new Vector2(150, 100);
            float   camRotation = MathF.Sin(Gametime.TotalElapsedSeconds) * MathF.PI * 2.0f;

            Matrix4x4 translate = Matrix4x4.CreateTranslation(camPosition.X, camPosition.Y, 0.0f);
            Matrix4x4 scale     = Matrix4x4.CreateScale(camScale.X, camScale.Y, 1.0f);
            Matrix4x4 rotate    = Matrix4x4.CreateRotationZ(camRotation);

            shader.SetMatrix4x4("model", scale * rotate * translate);

            //Apply basic shader to the vertices:
            shader.Use();
            shader.SetMatrix4x4("projection", camera.GetProjectionMatrix());

            glBindVertexArray(vao);
            glDrawArrays(GL_TRIANGLES, 0, 6);
            glBindVertexArray(0);

            Glfw.SwapBuffers(DisplayManager.Window);
        }