I'm trying to draw 3d objects that have more than 65536 vertices on the iPad, but can't figure out what I'm doing wrong. My original model that used GL_UNSIGNED_SHORT worked just fine, but now with GL_UNSIGNED_INT, I can't get anything to show up using the glDrawElements command. It's like the renderer is ignoring my glDrawElements line completely. The portion of my rendering loop that I'm referencing is below:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(assemblyObj->vertices[0])*6, &assemblyObj->vertices[0]);
glNormalPointer(GL_FLOAT, sizeof(assemblyObj->vertices[0])*6, &assemblyObj->vertices[0]);
for (int i = 0; i < assemblyObj->numObjects; i++)
{
glDrawElements(GL_TRIANGLES, assemblyObj->partList[i].faceArray.size(), GL_UNSIGNED_INT, &assemblyObj->partList[i].faceArray[0]);
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
vertices is defined as:
vector<float> vertices;
and each faceArray is defined as:
vector<UInt32> faceArray;
Any suggestions on what I'm doing wrong that is preventing my geometry from drawing?
When glDrawElements is called, it uses count sequential elements from an enabled array, starting at indices to construct a sequence of geometric primitives. mode specifies what kind of primitives are constructed and how the array elements construct these primitives. If more than one array is enabled, each is used.
With glDrawArrays, OpenGL pulls data from the enabled arrays in order, vertex 0, then vertex 1, then vertex 2, and so on. With glDrawElements, you provide a list of vertex numbers. OpenGL will go through the list of vertex numbers, pulling data for the specified vertices from the arrays.
Stock OpenGL ES does not support GL_UNSIGNED_INT
for indices.
From the GLES glDrawElements man page:
GL_INVALID_ENUM is generated if type is not GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT.
This restriction is relaxed when GL_OES_element_index_uint is supported.
If you don't have support on the target platform, your best bet is to munge your mesh in multiple sub-meshes with < 64K
indices for each.
As to ipad specifically, as far as I know, iOS does not support this extension (See Supported extensions), but you can verify the extension list on the actual device if you want to make sure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With