开发者

How do we get Indices for glDrawElements()?

I'm trying to use the Assimp library to import models to a rudimentary OpenGL application with VBO use.

If I understand it correctly glDrawElements is one of the ideal modern ways to draw things.

But how do we get that information from a 开发者_Python百科generic import library?

If you have specific Assimp library knowledge it's appreciated.

--

What is generally the process to generate these?


Collect all indices from aiMesh::mFaces in a single buffer. Make sure to pass aiProcess_Triangulate to Assimp as postprocessing flag (amongst aiProcess_JoinVertices and whatever seems useful to you), and skip over points and lines or handle them separately.

The various data streams in aiMesh - such as aiMesh::mVertices and aiMesh::mNormals need to be set as GL input data streams (glVertexPointer, ...).


From the documentation it looks like the aiFace::mIndices from an aiMesh::mFaces index into aiMesh::mVertices.

aiVector3D looks like it's laid out such that you should be able to able to just call glVertexPointer() with mVertices and use mIndices directly in your glDrawElements() call.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜