j riv
j riv

Reputation: 3699

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 generic import library?

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

--

What is generally the process to generate these?

Upvotes: 5

Views: 1889

Answers (2)

Alexander Gessler
Alexander Gessler

Reputation: 46607

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, ...).

Upvotes: 5

genpfault
genpfault

Reputation: 52084

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.

Upvotes: 1

Related Questions