Inheritance: IDisposable
Beispiel #1
0
		public Mesh (Shader shader)
		{
			this.vertexArrayId = GL.GenVertexArray ();
			this.Bind ();
			this.vBufferId = GL.GenBuffer ();
			GL.EnableVertexAttribArray (0);
			GL.BindBuffer (BufferTarget.ArrayBuffer, this.vBufferId);
			GL.VertexAttribPointer (0, 2, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);
			this.uvBufferId = GL.GenBuffer ();
			GL.EnableVertexAttribArray (1);
			GL.BindBuffer (BufferTarget.ArrayBuffer, this.uvBufferId);
			GL.VertexAttribPointer (1, 2, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);
			this.shader = shader;
		}
Beispiel #2
0
        public Mesh(Shader shader = null)
        {
            this.customBuffers = new Dictionary<int, VertexAttrib>();

            // use VAO if possible
            this.vertexArrayId = NewVAO();
            if (this.vertexArrayId > -1)
            {
                this.Bind();
            }

            // vertex
            this.vBufferId = NewVBO();
            GL.BindBuffer(BufferTarget.ArrayBuffer, this.vBufferId);
            int vertexAttribId = 0;
            GL.EnableVertexAttribArray(vertexAttribId);
            GL.VertexAttribPointer(vertexAttribId, 2, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);

            // uv
            this.uvBufferId = NewVBO();
            GL.BindBuffer(BufferTarget.ArrayBuffer, this.uvBufferId);
            int uvAttribId = 1;
            GL.EnableVertexAttribArray(uvAttribId);
            GL.VertexAttribPointer(uvAttribId, 2, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);

            // vc
            this.vcBufferId = NewVBO();
            GL.BindBuffer(BufferTarget.ArrayBuffer, this.vcBufferId);
            int vcAttribId = 2;
            GL.EnableVertexAttribArray(vcAttribId);
            GL.VertexAttribPointer(vcAttribId, 4, VertexAttribPointerType.Float, false, 0, IntPtr.Zero);

            if (shader == null)
            {
                shader = simpleShader;
                shader.SetUniform("tex", 0);
            }

            this.shader = shader;

            this.noMatrix = false;
            this.hasVertexColors = true;
            this.requireUseTexture = true;
        }