Exemple #1
0
        internal void CreateBuffers()
        {
            constantBuffer = new ConstantBuffer(graphicsDevice);
            constantBuffer.Create(Size);

            backBuffer = new DataBuffer(Size);
            Utilities.ClearMemory(backBuffer.DataPointer, 0x0, Size);
        }
Exemple #2
0
        protected override void Load()
        {
            base.Load();

            _chunkMeshMvp = new InputBuffer
            {
                ModelViewProjectionMatrix = Camera.GetViewMatrix() *
                                            Camera.GetProjectionMatrix(Window.Size.X, Window.Size.Y)
            };
            _chunkMeshMatrixBuffer = ConstantBuffer.Create(_chunkMeshMvp);
            _cubeMeshMvp           = new InputBuffer
            {
                ModelViewProjectionMatrix = Matrix4.CreateTranslation(0, 0, 0) *
                                            Camera.GetViewMatrix() *
                                            Camera.GetProjectionMatrix(Window.Size.X, Window.Size.Y)
            };
            _cubeMeshMatrixBuffer = ConstantBuffer.Create(_cubeMeshMvp);

            _chunkMeshInputLayout = _inputLayoutFactory.CreateInputLayout(VertexType.PositionColorTexture);
            _cubeMeshLayout       = _inputLayoutFactory.CreateInputLayout(VertexType.PositionColor);
            _simpleShader         = _shaderFactory.CreateFromFile(
                "Simple",
                "Content/Shaders/Simple.vs.glsl",
                "Content/Shaders/Simple.fs.glsl", out var allowedVertexType);
            _textureAtlas.Load();

            _cubeMesh = _meshFactory.CreateUnitCubeMesh();

            GL.Disable(EnableCap.CullFace);
            GL.CullFace(CullFaceMode.Back);
            GL.FrontFace(FrontFaceDirection.Ccw);

            GL.Enable(EnableCap.DepthTest);
            GL.DepthFunc(DepthFunction.Lequal);

            GL.Enable(EnableCap.Blend);
        }