GlBindTexture (GL_TEXTURE_2D texName [texFileNameIdx]);//texFileNameIdx is the indice of marketers texture
GlBegin (GL_TRIANGLES);
GlTexCoord2f (... );
GlVertex3f (... );
GlTexCoord2f (... );
GlVertex3f (... );
GlTexCoord2f (... );
GlVertex3f (... );
GlEnd ();
Because each triangle may be different texture map to render, so I call glBindTexture to bind different texture to the current unit, such a large number of points if the model speed will be slow, so I adopt the method of texture arrays, vertex and the normal vector of vertex arrays more easily, my code in the following:
GlGenBuffers (3, this - & gt; Buffers);
GlBindBuffer (GL_ARRAY_BUFFER, this - & gt; Buffers [VERTEXBUFFER]);
GlBufferData (GL_ARRAY_BUFFER, sizeof (GLfloat) * 3 * objInfo - & gt; Points3d. The size (), and this - & gt; Vertexs GL_STATIC_DRAW);
GlVertexPointer (3, GL_FLOAT, 0, BUFFER_OFFSET (0));
GlEnableClientState (GL_VERTEX_ARRAY);
GlBindBuffer (GL_ARRAY_BUFFER, this - & gt; Buffers [NORMALBUFFER]);
GlBufferData (GL_ARRAY_BUFFER, sizeof (GLfloat) * 3 * objInfo - & gt; Points3d. The size (), and this - & gt; Normals, GL_STATIC_DRAW);
GlNormalPointer (GL_FLOAT, 0, BUFFER_OFFSET (0));
GlEnableClientState (GL_NORMAL_ARRAY);
GlBindBuffer (GL_ELEMENT_ARRAY_BUFFER, this - & gt; Buffers [INDICEBUFFER]);
GlBufferData (GL_ELEMENT_ARRAY_BUFFER, sizeof (GLuint) * 3 * objInfo - & gt; Faces. The size (), and this - & gt; Indices, GL_STATIC_DRAW);
This code is to use a buffer object to store the vertex array, finally glDrawElements using this method to render,
A texture is better to get a little, but if there is one more texture chart?
CodePudding user response:
To help the top first!Then, want to ask the building Lord, your model will have a lot after modeling arrays and the normal vector of triangles, after a triangles in the painting you want to add texture to a triangles, due to the many triangles and texture, so you don't know is there any way to these triangles in texture painting is this? Please reply!
CodePudding user response:
I also encountered this problem, don't know the building Lord solveCodePudding user response:
Only an object, an object can't imagine other better way