Create the Vertex Buffer Objects used to render with OpenGL. We create two VBOs (one for vertices and one for indices)
| 175 | // Create the Vertex Buffer Objects used to render with OpenGL. |
| 176 | /// We create two VBOs (one for vertices and one for indices) |
| 177 | void Dumbbell::createVBOAndVAO() { |
| 178 | |
| 179 | // Create the VBO for the vertices data |
| 180 | mVBOVertices.create(); |
| 181 | mVBOVertices.bind(); |
| 182 | size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3); |
| 183 | mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW); |
| 184 | mVBOVertices.unbind(); |
| 185 | |
| 186 | // Create the VBO for the normals data |
| 187 | mVBONormals.create(); |
| 188 | mVBONormals.bind(); |
| 189 | size_t sizeNormals = mNormals.size() * sizeof(openglframework::Vector3); |
| 190 | mVBONormals.copyDataIntoVBO(sizeNormals, getNormalsPointer(), GL_STATIC_DRAW); |
| 191 | mVBONormals.unbind(); |
| 192 | |
| 193 | if (hasTexture()) { |
| 194 | // Create the VBO for the texture co data |
| 195 | mVBOTextureCoords.create(); |
| 196 | mVBOTextureCoords.bind(); |
| 197 | size_t sizeTextureCoords = mUVs.size() * sizeof(openglframework::Vector2); |
| 198 | mVBOTextureCoords.copyDataIntoVBO(sizeTextureCoords, getUVTextureCoordinatesPointer(), GL_STATIC_DRAW); |
| 199 | mVBOTextureCoords.unbind(); |
| 200 | } |
| 201 | |
| 202 | // Create th VBO for the indices data |
| 203 | mVBOIndices.create(); |
| 204 | mVBOIndices.bind(); |
| 205 | size_t sizeIndices = mIndices[0].size() * sizeof(unsigned int); |
| 206 | mVBOIndices.copyDataIntoVBO(sizeIndices, getIndicesPointer(), GL_STATIC_DRAW); |
| 207 | mVBOIndices.unbind(); |
| 208 | |
| 209 | // Create the VAO for both VBOs |
| 210 | mVAO.create(); |
| 211 | mVAO.bind(); |
| 212 | |
| 213 | // Bind the VBO of vertices |
| 214 | mVBOVertices.bind(); |
| 215 | |
| 216 | // Bind the VBO of normals |
| 217 | mVBONormals.bind(); |
| 218 | |
| 219 | if (hasTexture()) { |
| 220 | // Bind the VBO of texture coords |
| 221 | mVBOTextureCoords.bind(); |
| 222 | } |
| 223 | |
| 224 | // Bind the VBO of indices |
| 225 | mVBOIndices.bind(); |
| 226 | |
| 227 | // Unbind the VAO |
| 228 | mVAO.unbind(); |
| 229 | } |
nothing calls this directly
no test coverage detected