Game Development Reference
In-Depth Information
MeshEx Class Overview
The MeshEx class uses the glDrawElements() function to actually render the mesh. This function
uses the index method of rendering vertices, where a list of vertices is stored in the m_VertexBuffer
FloatBuffer variable along with an index list into these vertices of the triangles that need to be drawn
that are stored in the m_DrawListBuffer ShortBuffer variable.
The m_VertexBuffer holds a list of vertex data. Each vertex can have values for the position
coordinates, texture coordinates, and the vertex normal coordinates. Also, there are offsets into the
vertex data that indicate where the data actually starts for position, texture coordinates, and vertex
normals (see Figure 4-18 ). The figure also shows the vertex stride, which is the length in bytes of the
data of a single vertex.
m_VertexBuffer
Vertex 1
Vertex 2
m_MeshVerticesDataUVOffset
x,y,z
u,v
nx, ny, nz
x,y,z
u,v
nx, ny, nz
m_MeshVerticesDataNormalOffset
m_MeshVerticesDataPosOffset
m_MeshVerticesDataStrideBytes
Figure 4-18. The vertex buffer
The m_DrawListBuffer holds an array of numbers that map into a vertex in the m_VertexBuffer array
(see Figure 4-19 ).
 
Search WWH ::




Custom Search