Exemple #1
0
        private static void OnLoad()
        {
            StartTime = DateTime.UtcNow;
            var input = window.CreateInput();

            primaryKeyboard = input.Keyboards.FirstOrDefault();
            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += KeyDown;
            }
            for (var i = 0; i < input.Mice.Count; i++)
            {
                input.Mice[i].Cursor.CursorMode = CursorMode.Raw;
                input.Mice[i].MouseMove        += OnMouseMove;
                input.Mice[i].Scroll           += OnMouseWheel;
            }

            Gl = GL.GetApi(window);

            Ebo     = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo     = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            VaoCube = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            VaoCube.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 6, 0);
            VaoCube.VertexAttributePointer(1, 3, VertexAttribPointerType.Float, 6, 3);

            //The lighting shader will give our main cube its colour multiplied by the lights intensity
            LightingShader = new Shader(Gl, "shader.vert", "lighting.frag");
            //The Lamp shader uses a fragment shader that just colours it solid white so that we know it is the light source
            LampShader = new Shader(Gl, "shader.vert", "shader.frag");

            //Start a camera at position 3 on the Z axis, looking at position -1 on the Z axis
            Camera = new Camera(Vector3.UnitZ * 6, Vector3.UnitZ * -1, Vector3.UnitY, Width / Height);
        }
Exemple #2
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            primaryKeyboard = input.Keyboards.FirstOrDefault();
            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += KeyDown;
            }
            for (int i = 0; i < input.Mice.Count; i++)
            {
                input.Mice[i].Cursor.CursorMode = CursorMode.Raw;
                input.Mice[i].MouseMove        += OnMouseMove;
                input.Mice[i].Scroll           += OnMouseWheel;
            }

            Gl = GL.GetApi(window);

            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 5, 0);
            Vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 5, 3);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");

            Texture = new Texture(Gl, "silk.png");
        }
        public VertexArrayObject(GL gl, BufferObject <TVertexType> vbo, BufferObject <TIndexType> ebo)
        {
            _gl = gl;

            _handle = _gl.GenVertexArray();
            Bind();
            vbo.Bind();
            ebo.Bind();
        }
Exemple #4
0
        public VertexArrayObject(GL gl, BufferObject <TVertexType> vbo, BufferObject <TIndexType> ebo)
        {
            //Saving the GL instance.
            _gl = gl;

            //Setting out handle and binding the VBO and EBO to this VAO.
            _handle = _gl.GenVertexArray();
            Bind();
            vbo.Bind();
            ebo.Bind();
        }
Exemple #5
0
        private static void OnLoad()
        {
            var input = window.CreateInput();

            for (var i = 0; i < input.Keyboards.Count; i++)
            {
                input.Keyboards[i].KeyDown += KeyDown;
            }

            Gl = GL.GetApi(window);

            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 5, 0);
            Vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 5, 3);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");

            Texture = new Texture(Gl, "silk.png");

            //Unlike in the transformation, because of our abstraction order dosent matter here.
            //Translation.
            Transforms[0] = new Transform
            {
                Position = new Vector3(0.5f, 0.5f, 0f)
            };
            //Rotation.
            Transforms[1] = new Transform
            {
                Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, 1f)
            };
            //Scaling.
            Transforms[2] = new Transform
            {
                Scale = 0.5f
            };
            //Mixed transformation.
            Transforms[3] = new Transform
            {
                Position = new Vector3(-0.5f, 0.5f, 0f),
                Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, 1f),
                Scale    = 0.5f
            };
        }
Exemple #6
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            for (int i = 0; i < input.Keyboards.Count; i++)
            {
                input.Keyboards[i].KeyDown += KeyDown;
            }

            Gl = GL.GetApi(window);

            //Instantiating our new abstractions
            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            //Telling the VAO object how to lay out the attribute pointers
            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 7, 0);
            Vao.VertexAttributePointer(1, 4, VertexAttribPointerType.Float, 7, 3);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");
        }
Exemple #7
0
        private static void OnLoad()
        {
            IInputContext input = window.CreateInput();

            for (int i = 0; i < input.Keyboards.Count; i++)
            {
                input.Keyboards[i].KeyDown += KeyDown;
            }

            Gl = GL.GetApi(window);

            Ebo = new BufferObject <uint>(Gl, Indices, BufferTargetARB.ElementArrayBuffer);
            Vbo = new BufferObject <float>(Gl, Vertices, BufferTargetARB.ArrayBuffer);
            Vao = new VertexArrayObject <float, uint>(Gl, Vbo, Ebo);

            Vao.VertexAttributePointer(0, 3, VertexAttribPointerType.Float, 5, 0);
            Vao.VertexAttributePointer(1, 2, VertexAttribPointerType.Float, 5, 3);

            Shader = new Shader(Gl, "shader.vert", "shader.frag");

            Texture = new Texture(Gl, "silk.png");
        }