Example #1
0
        public static Mesh generateTextureQuad()
        {
            VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.TexCoords(0));
            Mesh             mesh  = new Mesh(true, 4, 5, attrs);

            mesh.setVerticies(ref quadTextureVerts);
            mesh.setIndicies(ref quadTextureIndencies);

            return(mesh);
        }
Example #2
0
        private int calculateOffsets()
        {
            int count = 0;

            for (int i = 0; i < this.attributes.Length; i++)
            {
                VertexAttribute attr = this.attributes[i];
                attr.offset = count;
                count      += 4 * attr.numComponents;
            }
            return(count);
        }
Example #3
0
        public void unbind(ref Shader shader)
        {
            for (int i = 0; i < attributes.size(); i++)
            {
                VertexAttribute attr     = attributes.get(i);
                int             location = shader.attribute(attr.alias);

                GL.DisableVertexAttribArray(location);
            }

            GL.BindBuffer(BufferTarget.ArrayBuffer, 0);
        }
Example #4
0
        public void bind(ref Shader shader)
        {
            GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);

            if (dirty)
            {
                bufferChange();
                dirty = false;
            }

            for (int i = 0; i < attributes.size(); i++)
            {
                VertexAttribute attr     = attributes.get(i);
                int             location = shader.attribute(attr.alias);
                GL.EnableVertexAttribArray(location);
                GL.VertexAttribPointer(location, attr.numComponents, VertexAttribPointerType.Float, false, attributes.vertexSize, attr.offset);
            }
        }
Example #5
0
        public static Mesh screenQuad(ref Camera camera, int textureUnit)
        {
            VertexAttributes attrs = new VertexAttributes(VertexAttribute.Position(), VertexAttribute.TexCoords(textureUnit));
            Mesh             mesh  = new Mesh(true, 4, 5, attrs);

            Vector3 vec0 = Vector3.Zero;

            camera.unproject(ref vec0);

            Vector3 vec1 = new Vector3(Game.shared.width, Game.shared.height, 0);

            camera.unproject(ref vec1);

            mesh.setVertices(new float[] {
                vec0.X, vec0.Y, 0, 0, 1,
                vec1.X, vec0.Y, 0, 1, 1,
                vec1.X, vec1.Y, 0, 1, 0,
                vec0.X, vec1.Y, 0, 0, 0
            });
            mesh.setIndices(new uint[] { 0, 1, 2, 2, 3, 0 });

            return(mesh);
        }