private void SetupShaderProgram(ShaderProgram program, ref Matrix4 projection)
        {
            this.context.UseShaderProgram(program);
            program.SetUniform("projection_matrix", ref projection);

            int posIndex = program.GetAttributeLocation("in_position");
            int coloIndex = program.GetAttributeLocation("in_tint");

            GL.BindVertexArray(this.vba);

            this.context.BindVertexBuffer(this.vertexBuffer);
            this.context.EnableVertexAttribArray(posIndex);
            this.context.EnableVertexAttribArray(coloIndex);

            this.context.VertexAttribPointer(posIndex, 2, VertexAttribPointerType.Float,
                                             true, this.vertecies[0].SizeInBytes, 0);

            this.context.VertexAttribPointer(coloIndex, 4, VertexAttribPointerType.UnsignedByte,
                                             true, this.vertecies[0].SizeInBytes, Vector2.SizeInBytes);

            GL.BindVertexArray(0);
        }
Esempio n. 2
0
        private void SetupShaderProgram(ShaderProgram program, ref Matrix4 projection)
        {
            this.context.UseShaderProgram(program);
            program.SetUniform("projection_matrix", ref projection);

            int posIndex  = program.GetAttributeLocation("in_position");
            int coloIndex = program.GetAttributeLocation("in_tint");

            GL.BindVertexArray(this.vba);

            this.context.BindVertexBuffer(this.vertexBuffer);
            this.context.EnableVertexAttribArray(posIndex);
            this.context.EnableVertexAttribArray(coloIndex);

            this.context.VertexAttribPointer(posIndex, 2, VertexAttribPointerType.Float,
                                             true, this.vertecies[0].SizeInBytes, 0);

            this.context.VertexAttribPointer(coloIndex, 4, VertexAttribPointerType.UnsignedByte,
                                             true, this.vertecies[0].SizeInBytes, Vector2.SizeInBytes);

            GL.BindVertexArray(0);
        }
Esempio n. 3
0
        //Prepares the supplied effect for drawing.
        private void PrepareShaderProgram(ref Matrix4 transformation, ShaderProgram program)
        {
            this.GraphicsContext.UseShaderProgram(program);
            program.SetUniform("tex", 0);
            program.SetUniform("projection_matrix", ref transformation);

            int posIndex      = program.GetAttributeLocation("in_position");
            int texIndex      = program.GetAttributeLocation("in_coords");
            int coloIndex     = program.GetAttributeLocation("in_tint");
            int rotationIndex = program.GetAttributeLocation("in_rotation");

            GL.BindVertexArray(this.vertexArrayHandle);

            this.GraphicsContext.BindVertexBuffer(this.vertexBuffer);
            this.GraphicsContext.EnableVertexAttribArray(posIndex);
            this.GraphicsContext.EnableVertexAttribArray(texIndex);
            this.GraphicsContext.EnableVertexAttribArray(coloIndex);
            this.GraphicsContext.EnableVertexAttribArray(rotationIndex);

            this.GraphicsContext.VertexAttribPointer(posIndex, 4, VertexAttribPointerType.Float, true, this.vertices[0].SizeInBytes, 0);
            this.GraphicsContext.VertexAttribPointer(texIndex, 2, VertexAttribPointerType.Float, true, this.vertices[0].SizeInBytes, Vector4.SizeInBytes);
            this.GraphicsContext.VertexAttribPointer(coloIndex, 4, VertexAttribPointerType.UnsignedByte, true, this.vertices[0].SizeInBytes, Vector4.SizeInBytes + Vector2.SizeInBytes);
            this.GraphicsContext.VertexAttribPointer(rotationIndex, 1, VertexAttribPointerType.Float, true, this.vertices[0].SizeInBytes, Vector4.SizeInBytes + Vector2.SizeInBytes + sizeof(int));
        }