Exemple #1
0
        public void BindAttributes(ShaderProgram program)
        {
            GenericVBO elementArray = new GenericVBO(0, "", 0, 0, VertexAttribPointerType.Byte, BufferTarget.ArrayBuffer);

            for (int i = 0; i < vbos.Length; i++)
            {
                if (vbos[i].bufferTarget == BufferTarget.ElementArrayBuffer)
                {
                    elementArray = vbos[i];
                    continue;
                }

                int loc = Gl.GetAttribLocation(program.ProgramID, vbos[i].name);
                if (loc == -1)
                {
                    throw new Exception(string.Format("Shader did not contain '{0}'.", vbos[i].name));
                }

                Gl.EnableVertexAttribArray((uint)loc);
                Gl.BindBuffer(vbos[i].bufferTarget, vbos[i].vboID);
                Gl.VertexAttribPointer((uint)loc, vbos[i].size, vbos[i].pointerType, true, vbos[i].size * SizeOfType(vbos[i].pointerType), IntPtr.Zero);
            }

            if (elementArray.vboID != 0)
            {
                Gl.BindBuffer(BufferTarget.ElementArrayBuffer, elementArray.vboID);
                VertexCount = elementArray.length;
            }
        }
Exemple #2
0
        public VAO(ShaderProgram program, VBO <T1> vbo1, string attribName, VBO <int> elementArray)
            : base(program)
        {
            GenericVAO.GenericVBO[] vbos = new GenericVBO[2];
            vbos[0] = new GenericVBO(vbo1.vboID, attribName, vbo1.Count, vbo1.Size, vbo1.PointerType, vbo1.BufferTarget);
            vbos[1] = new GenericVBO(elementArray.vboID, "", elementArray.Count, elementArray.Size, elementArray.PointerType, elementArray.BufferTarget);

            Init(vbos);
        }
Exemple #3
0
        public VAO(ShaderProgram program, VBO <T1> vbo1, string attribName, VBO <int> elementArray)
            : base(program)
        {
            IGenericVBO[] vbos = new IGenericVBO[2];
            vbos[0] = new GenericVBO <T1>(vbo1, attribName);
            vbos[1] = new GenericVBO <int>(elementArray);

            Init(vbos);
        }
Exemple #4
0
        public VAO(ShaderProgram program, VBO <T1> vbo1, string[] attribNames, VBO <int> elementArray)
            : base(program)
        {
            if (attribNames.Length != 1)
            {
                throw new Exception(string.Format("Expected an array of 1 name, but instead got {0}.", attribNames.Length));
            }

            GenericVAO.GenericVBO[] vbos = new GenericVBO[2];
            vbos[0] = new GenericVBO(vbo1.vboID, attribNames[0], vbo1.Count, vbo1.Size, vbo1.PointerType, vbo1.BufferTarget);
            vbos[1] = new GenericVBO(elementArray.vboID, "", elementArray.Count, elementArray.Size, elementArray.PointerType, elementArray.BufferTarget);

            Init(vbos);
        }
Exemple #5
0
        public VAO(ShaderProgram program, VBO <T1> vbo1, string[] attribNames, VBO <int> elementArray)
            : base(program)
        {
            if (attribNames.Length != 1)
            {
                throw new Exception(string.Format("Expected an array of 1 name, but instead got {0}.", attribNames.Length));
            }

            IGenericVBO[] vbos = new IGenericVBO[2];
            vbos[0] = new GenericVBO <T1>(vbo1, attribNames[0]);
            vbos[1] = new GenericVBO <int>(elementArray);

            Init(vbos);
        }