Esempio n. 1
0
        public override void Create()
        {
            VAO = new("Cubemap VAO");
            VBO = new("Cubemap VBO");

            VAO.Bind();

            VBO.Bind(BufferTarget.ArrayBuffer);

            VBO.Data(skyboxVertices, BufferUsageHint.DynamicDraw);

            var VS = File.ReadAllText("EngineResources/Shaders/Cubemap/cubemap.vert");
            var FS = File.ReadAllText("EngineResources/Shaders/Cubemap/cubemap.frag");

            var VP = new GLShader(VS, GLShaderType.Vertex);
            var FP = new GLShader(FS, GLShaderType.Fragment);

            CubemapShader = new GLShaderProgram()
                            .Label("Cubemap Shader")
                            .Attach(VP)
                            .Attach(FP)
                            .Link();

            GL.EnableVertexAttribArray(0);
            GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0);

            GL.BindVertexArray(0);
        }
Esempio n. 2
0
        private unsafe void SetUp()
        {
            VAO = new("Mesh VAO");
            VBO = new("Mesh VBO");
            EBO = new("Mesh EBO");

            VAO.Bind();
            VBO.Bind(BufferTarget.ArrayBuffer);

            // Buffer the vertex data into the VBO.
            var verarr = CollectionsMarshal.AsSpan(Vertices);

            GL.BufferData(BufferTarget.ArrayBuffer, verarr.Length * sizeof(Vertex), ref verarr[0], BufferUsageHint.StaticDraw);

            EBO.Bind(BufferTarget.ElementArrayBuffer);

            // Buffer the element array into the EBO.
            var indarr = CollectionsMarshal.AsSpan(Indices);

            GL.BufferData(BufferTarget.ElementArrayBuffer, indarr.Length * sizeof(uint), ref indarr[0], BufferUsageHint.StaticDraw);

            SetupPointers();

            GL.BindVertexArray(0);
        }