I have three textures(three .jpg image).In general.I render a triangle with the below code
glBindTexture(GL_TEXTURE_2D, texName[texFileNameIdx]); //texFileNameIdx is the indice of different texture
glBegin(GL_TRIANGLES);
glTexCoord2f(...);
glVertex3f(...);
glTexCoord2f(...);
glVertex3f(...);
glTexCoord2f(...);
glVertex3f(...);
glEnd();
before rendering a triangle,I bind texture with glBindTexture first because different triangles maybe rendering with different texture.
but it will result in low efficiency.So I leanrn to use vertex array.Now I have question.how to render a model with vertex array if I have two or more
texture image.
I init the buffer first just as the Opengl programming guide book did.But dont know how to init the buffer correspond to texture and how to draw it.
glGenBuffers(3, this->buffers);
glBindBuffer(GL_ARRAY_BUFFER, this->buffers[VERTEXBUFFER]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3*objInfo->points3d.size(), this->vertexs, GL_STATIC_DRAW);
glVertexPointer(3, GL_FLOAT, 0, BUFFER_OFFSET(0));
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, this->buffers[NORMALBUFFER]);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat)*3*objInfo->points3d.size(), this->normals, GL_STATIC_DRAW);
glNormalPointer(GL_FLOAT, 0, BUFFER_OFFSET(0));
glEnableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->buffers[INDICEBUFFER]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLuint)*3*objInfo->faces.size(), this->indices, GL_STATIC_DRAW);