Beispiel #1
0
        protected override void Render(FrameEventArgs e)
        {
            GL.Viewport(0, 0, Window.Size.X, Window.Size.Y);
            GL.ClearColor(_clearColor);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

            _chunkMeshMvp.ModelViewProjectionMatrix = Matrix4.CreateScale(1, 1, 1) *
                                                      Camera.GetViewMatrix() *
                                                      Camera.GetProjectionMatrix(Window.Size.X, Window.Size.Y);
            _cubeMeshMvp.ModelViewProjectionMatrix = Matrix4.CreateTranslation(Camera.Position) *
                                                     Matrix4.CreateScale(2, 2, 2) *
                                                     Camera.GetViewMatrix() *
                                                     Camera.GetProjectionMatrix(Window.Size.X, Window.Size.Y);

            _chunkMeshMatrixBuffer.Bind(0);
            _chunkMeshMatrixBuffer.UpdateBuffer(_chunkMeshMvp);

            _simpleShader.Use();
            GL.BindTextureUnit(0, _textureAtlas.AtlasTexture.GLTexture);

            _chunkMeshInputLayout.Use(_chunkMesh);
            _chunkMesh.Draw();

            _cubeMeshLayout.Use(_cubeMesh);
            _cubeMeshMatrixBuffer.Bind(0);
            _cubeMesh.Draw();

            if (ImGui.Begin("TestWindow"))
            {
                if (ImGui.InputFloat3("Camera Raw", ref _cameraPositionRaw))
                {
                }

                if (ImGui.InputFloat3("Camera", ref _cameraPosition))
                {
                }

                if (ImGui.InputFloat2("Chunk Position", ref _chunkPosition))
                {
                }

                if (ImGui.Button("Close"))
                {
                    Window.Close();
                }

                ImGui.End();
            }

            base.Render(e);
        }