public void Bind(GLShader shader, GLTexture texture = null, GLTexture texture2 = null, GLTexture texture3 = null, GLTexture texture4 = null) { if (posbuffer == -1) // Mesh without vertex positions can't be rendered { return; } /*for(var i = 0; i < 16; i++) * GL.DisableVertexAttribArray(i); * * GL.EnableVertexAttribArray(sdr.vertexPositionAttribute);*/ GL.BindBuffer(BufferTarget.ArrayBuffer, posbuffer); GL.EnableClientState(ArrayCap.VertexArray); GL.VertexPointer(3, VertexPointerType.Float, 0, IntPtr.Zero); /*GL.VertexAttribPointer(sdr.vertexPositionAttribute, 3, VertexAttribType.Float, false, 0, 0);*/ if (nmlbuffer != -1 /*&& sdr.vertexNormalAttribute != -1*/) { /*GL.EnableVertexAttribArray(sdr.vertexNormalAttribute);*/ GL.BindBuffer(BufferTarget.ArrayBuffer, nmlbuffer); /*GL.VertexAttribPointer(sdr.vertexNormalAttribute, 3, gl.FLOAT, false, 0, 0);*/ } /*if(tgtbuffer != -1 && sdr.vertexTangentAttribute != -1) * { * GL.EnableVertexAttribArray(sdr.vertexTangentAttribute); * GL.BindBuffer(BufferTarget.ArrayBuffer, tgtbuffer); * GL.VertexAttribPointer(sdr.vertexTangentAttribute, 3, gl.FLOAT, false, 0, 0); * } * if(bnmbuffer != -1 && sdr.vertexBinormalAttribute != -1) * { * GL.EnableVertexAttribArray(sdr.vertexBinormalAttribute); * GL.BindBuffer(BufferTarget.ArrayBuffer, bnmbuffer); * GL.VertexAttribPointer(sdr.vertexBinormalAttribute, 3, gl.FLOAT, false, 0, 0); * }*/ if (texcoordbuffer != -1 && shader.defattrs.texcoord != -1) { GL.EnableVertexAttribArray(shader.defattrs.texcoord); GL.BindBuffer(BufferTarget.ArrayBuffer, texcoordbuffer); GL.VertexAttribPointer(shader.defattrs.texcoord, 2, VertexAttribPointerType.Float, false, 0, 0); } if (texture != null) { GL.ActiveTexture(TextureUnit.Texture0); texture.Bind(); if (shader != null) { shader.SetTexture(0); } } if (texture2 != null) { GL.ActiveTexture(TextureUnit.Texture1); texture2.Bind(); if (shader != null) { shader.SetTexture(1); } } if (texture3 != null) { GL.ActiveTexture(TextureUnit.Texture2); texture3.Bind(); if (shader != null) { shader.SetTexture(2); } } if (texture4 != null) { GL.ActiveTexture(TextureUnit.Texture3); texture4.Bind(); if (shader != null) { shader.SetTexture(3); } } if (idxbuffer != -1) { GL.BindBuffer(BufferTarget.ElementArrayBuffer, idxbuffer); } }
public void Bind(GLShader shader, GLTexture texture = null, GLTexture texture2 = null, GLTexture texture3 = null, GLTexture texture4 = null) { if(posbuffer == -1) // Mesh without vertex positions can't be rendered return; /*for(var i = 0; i < 16; i++) GL.DisableVertexAttribArray(i); GL.EnableVertexAttribArray(sdr.vertexPositionAttribute);*/ GL.BindBuffer(BufferTarget.ArrayBuffer, posbuffer); GL.EnableClientState(ArrayCap.VertexArray); GL.VertexPointer(3, VertexPointerType.Float, 0, IntPtr.Zero); /*GL.VertexAttribPointer(sdr.vertexPositionAttribute, 3, VertexAttribType.Float, false, 0, 0);*/ if(nmlbuffer != -1 /*&& sdr.vertexNormalAttribute != -1*/) { /*GL.EnableVertexAttribArray(sdr.vertexNormalAttribute);*/ GL.BindBuffer(BufferTarget.ArrayBuffer, nmlbuffer); /*GL.VertexAttribPointer(sdr.vertexNormalAttribute, 3, gl.FLOAT, false, 0, 0);*/ } /*if(tgtbuffer != -1 && sdr.vertexTangentAttribute != -1) { GL.EnableVertexAttribArray(sdr.vertexTangentAttribute); GL.BindBuffer(BufferTarget.ArrayBuffer, tgtbuffer); GL.VertexAttribPointer(sdr.vertexTangentAttribute, 3, gl.FLOAT, false, 0, 0); } if(bnmbuffer != -1 && sdr.vertexBinormalAttribute != -1) { GL.EnableVertexAttribArray(sdr.vertexBinormalAttribute); GL.BindBuffer(BufferTarget.ArrayBuffer, bnmbuffer); GL.VertexAttribPointer(sdr.vertexBinormalAttribute, 3, gl.FLOAT, false, 0, 0); }*/ if(texcoordbuffer != -1 && shader.defattrs.texcoord != -1) { GL.EnableVertexAttribArray(shader.defattrs.texcoord); GL.BindBuffer(BufferTarget.ArrayBuffer, texcoordbuffer); GL.VertexAttribPointer(shader.defattrs.texcoord, 2, VertexAttribPointerType.Float, false, 0, 0); } if(texture != null) { GL.ActiveTexture(TextureUnit.Texture0); texture.Bind(); if(shader != null) shader.SetTexture(0); } if(texture2 != null) { GL.ActiveTexture(TextureUnit.Texture1); texture2.Bind(); if(shader != null) shader.SetTexture(1); } if(texture3 != null) { GL.ActiveTexture(TextureUnit.Texture2); texture3.Bind(); if(shader != null) shader.SetTexture(2); } if(texture4 != null) { GL.ActiveTexture(TextureUnit.Texture3); texture4.Bind(); if(shader != null) shader.SetTexture(3); } if(idxbuffer != -1) GL.BindBuffer(BufferTarget.ElementArrayBuffer, idxbuffer); }