Ejemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            float[] vertices =
            {
                0.5f,   0.5f, 0.0f, 1.0f, 1.0f,
                0.5f,  -0.5f, 0.0f, 1.0f, 0.0f,
                -0.5f, -0.5f, 0.0f, 0.0f, 0.0f,
                -0.5f,  0.5f, 0.0f, 0.0f, 1.0f
            };
            uint[] indices =
            {
                0, 1, 3,
                1, 2, 3
            };
            _vbo    = new BufferObject();
            _ebo    = new BufferObject();
            _layout = new BufferLayout();
            _vao    = new VertexArrayObject();

            _vbo.SetData(BufferTarget.ArrayBuffer, vertices);
            _ebo.SetData(BufferTarget.ElementArrayBuffer, indices);

            _layout.AddLayoutItem(VertexAttribPointerType.Float, 3);
            _layout.AddLayoutItem(VertexAttribPointerType.Float, 2);

            _vao.AddBuffer(ref _ebo);
            _vao.AddBuffer(ref _vbo, _layout);


            _shader  = new Shader("shader.vert", "shader.frag");
            _texture = new Texture("test");

            _transform = new Transform();
            _camera    = new Camera(Width, Height);
            _transform.SetShader(ref _shader);
            _camera.ApplyToShader(ref _shader);

            GL.ClearColor(1f, 1f, 1f, 1f);

            base.OnLoad(e);
        }