示例#1
0
        protected override void OnLoad(EventArgs e)
        {
            GL.ClearColor(Color4.DarkSlateGray);
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.VertexProgramPointSize);

            program = new ShaderProgram()
                      .AttachShader(Shader.FromFile("./Assets/Shader/Fragment.glsl", ShaderType.FragmentShader))
                      .AttachShader(Shader.FromFile("./Assets/Shader/Vertex.glsl", ShaderType.VertexShader))
                      .Link();

            hudprogram = new ShaderProgram()
                         .AttachShader(Shader.FromFile("./Assets/Shader/HudFragment.glsl", ShaderType.FragmentShader))
                         .AttachShader(Shader.FromFile("./Assets/Shader/HudVertex.glsl", ShaderType.VertexShader))
                         .Link();

            texture = Texture.FromFiles(256, Block.Textures);
            texture.SetFiltering(TextureMinFilter.LinearMipmapLinear, TextureMagFilter.Linear);
            texture.SetLODBias(-0.7f);

            aoTexture = AmbientOcclusion.GetAOTexture4();//Texture.FromFile("./Assets/Textures/ao.png");
            aoTexture.SetWarpMode(TextureWrapMode.MirroredRepeat);

            Console.WriteLine(GL.GetError());

            camera = new Camera(75f * (float)Math.PI / 180, (float)Width / (float)Height, 0.1f, 300.0f)
            {
                Position = new Vector3(8, 50, 8)
            };
            frustum = new Frustum(camera.CameraMatrix);

            world = new BlockWorld();

            Resize += (sender, ea) => {
                GL.Viewport(0, 0, Width, Height);
                camera.Aspect = (float)Width / (float)Height;
            };
            GC.Collect();
            base.OnLoad(e);
        }