MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / createVBOAndVAO

Method createVBOAndVAO

testbed/common/VisualContactPoint.cpp:200–238  ·  view source on GitHub ↗

Create the Vertex Buffer Objects used to render the contact point sphere with OpenGL. We create two VBOs (one for vertices and one for indices)

Source from the content-addressed store, hash-verified

198// Create the Vertex Buffer Objects used to render the contact point sphere with OpenGL.
199/// We create two VBOs (one for vertices and one for indices)
200void VisualContactPoint::createVBOAndVAO() {
201
202 // Create the VBO for the vertices data
203 mVBOVertices.create();
204 mVBOVertices.bind();
205 size_t sizeVertices = mMesh.getVertices().size() * sizeof(openglframework::Vector3);
206 mVBOVertices.copyDataIntoVBO(sizeVertices, mMesh.getVerticesPointer(), GL_STATIC_DRAW);
207 mVBOVertices.unbind();
208
209 // Create the VBO for the normals data
210 mVBONormals.create();
211 mVBONormals.bind();
212 size_t sizeNormals = mMesh.getNormals().size() * sizeof(openglframework::Vector3);
213 mVBONormals.copyDataIntoVBO(sizeNormals, mMesh.getNormalsPointer(), GL_STATIC_DRAW);
214 mVBONormals.unbind();
215
216 // Create th VBO for the indices data
217 mVBOIndices.create();
218 mVBOIndices.bind();
219 size_t sizeIndices = mMesh.getIndices(0).size() * sizeof(unsigned int);
220 mVBOIndices.copyDataIntoVBO(sizeIndices, mMesh.getIndicesPointer(), GL_STATIC_DRAW);
221 mVBOIndices.unbind();
222
223 // Create the VAO for both VBOs
224 mVAO.create();
225 mVAO.bind();
226
227 // Bind the VBO of vertices
228 mVBOVertices.bind();
229
230 // Bind the VBO of normals
231 mVBONormals.bind();
232
233 // Bind the VBO of indices
234 mVBOIndices.bind();
235
236 // Unbind the VAO
237 mVAO.unbind();
238}
239
240// Create the Vertex Buffer Objects used to render the contact normal line
241void VisualContactPoint::createContactNormalLineVBOAndVAO() {

Callers

nothing calls this directly

Calls 9

getVerticesMethod · 0.80
copyDataIntoVBOMethod · 0.80
getVerticesPointerMethod · 0.80
getNormalsPointerMethod · 0.80
getIndicesPointerMethod · 0.80
createMethod · 0.45
bindMethod · 0.45
sizeMethod · 0.45
unbindMethod · 0.45

Tested by

no test coverage detected