Create the Vertex Buffer Objects used to render with OpenGL. We create two VBOs (one for vertices and one for indices)
| 153 | // Create the Vertex Buffer Objects used to render with OpenGL. |
| 154 | /// We create two VBOs (one for vertices and one for indices) |
| 155 | void Capsule::createVBOAndVAO() { |
| 156 | |
| 157 | // Create the VBO for the vertices data |
| 158 | mVBOVertices.create(); |
| 159 | mVBOVertices.bind(); |
| 160 | size_t sizeVertices = mVertices.size() * sizeof(openglframework::Vector3); |
| 161 | mVBOVertices.copyDataIntoVBO(sizeVertices, getVerticesPointer(), GL_STATIC_DRAW); |
| 162 | mVBOVertices.unbind(); |
| 163 | |
| 164 | // Create the VBO for the normals data |
| 165 | mVBONormals.create(); |
| 166 | mVBONormals.bind(); |
| 167 | size_t sizeNormals = mNormals.size() * sizeof(openglframework::Vector3); |
| 168 | mVBONormals.copyDataIntoVBO(sizeNormals, getNormalsPointer(), GL_STATIC_DRAW); |
| 169 | mVBONormals.unbind(); |
| 170 | |
| 171 | if (hasTexture()) { |
| 172 | // Create the VBO for the texture co data |
| 173 | mVBOTextureCoords.create(); |
| 174 | mVBOTextureCoords.bind(); |
| 175 | size_t sizeTextureCoords = mUVs.size() * sizeof(openglframework::Vector2); |
| 176 | mVBOTextureCoords.copyDataIntoVBO(sizeTextureCoords, getUVTextureCoordinatesPointer(), GL_STATIC_DRAW); |
| 177 | mVBOTextureCoords.unbind(); |
| 178 | } |
| 179 | |
| 180 | // Create th VBO for the indices data |
| 181 | mVBOIndices.create(); |
| 182 | mVBOIndices.bind(); |
| 183 | size_t sizeIndices = mIndices[0].size() * sizeof(unsigned int); |
| 184 | mVBOIndices.copyDataIntoVBO(sizeIndices, getIndicesPointer(), GL_STATIC_DRAW); |
| 185 | mVBOIndices.unbind(); |
| 186 | |
| 187 | // Create the VAO for both VBOs |
| 188 | mVAO.create(); |
| 189 | mVAO.bind(); |
| 190 | |
| 191 | // Bind the VBO of vertices |
| 192 | mVBOVertices.bind(); |
| 193 | |
| 194 | // Bind the VBO of normals |
| 195 | mVBONormals.bind(); |
| 196 | |
| 197 | if (hasTexture()) { |
| 198 | // Bind the VBO of texture coords |
| 199 | mVBOTextureCoords.bind(); |
| 200 | } |
| 201 | |
| 202 | // Bind the VBO of indices |
| 203 | mVBOIndices.bind(); |
| 204 | |
| 205 | // Unbind the VAO |
| 206 | mVAO.unbind(); |
| 207 | } |
nothing calls this directly
no test coverage detected