| 188 | } |
| 189 | |
| 190 | void Geometry::Draw(GLsizei numInstances) |
| 191 | { |
| 192 | const GLint vboOffset = static_cast<GLint>(GetVboParams().offset / numElementsPerVertex_ / sizeof(GLfloat)) + firstVertex_; |
| 193 | |
| 194 | void* iboOffsetPtr = nullptr; |
| 195 | if (numIndices_ > 0) { |
| 196 | iboOffsetPtr = reinterpret_cast<void*>(GetIboParams().offset + firstIndex_ * sizeof(GLushort)); |
| 197 | } |
| 198 | |
| 199 | if (numInstances == 0) { |
| 200 | if (numIndices_ > 0) { |
| 201 | #if (defined(WITH_OPENGLES) && !GL_ES_VERSION_3_2) || defined(DEATH_TARGET_EMSCRIPTEN) |
| 202 | glDrawElements(primitiveType_, numIndices_, GL_UNSIGNED_SHORT, iboOffsetPtr); |
| 203 | #else |
| 204 | glDrawElementsBaseVertex(primitiveType_, numIndices_, GL_UNSIGNED_SHORT, iboOffsetPtr, vboOffset); |
| 205 | #endif |
| 206 | } else { |
| 207 | glDrawArrays(primitiveType_, vboOffset, numVertices_); |
| 208 | } |
| 209 | } else if (numInstances > 0) { |
| 210 | if (numIndices_ > 0) { |
| 211 | #if (defined(WITH_OPENGLES) && !GL_ES_VERSION_3_2) || defined(DEATH_TARGET_EMSCRIPTEN) |
| 212 | glDrawElementsInstanced(primitiveType_, numIndices_, GL_UNSIGNED_SHORT, iboOffsetPtr, numInstances); |
| 213 | #else |
| 214 | glDrawElementsInstancedBaseVertex(primitiveType_, numIndices_, GL_UNSIGNED_SHORT, iboOffsetPtr, numInstances, vboOffset); |
| 215 | #endif |
| 216 | } else { |
| 217 | glDrawArraysInstanced(primitiveType_, vboOffset, numVertices_, numInstances); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | void Geometry::CommitVertices() |
| 223 | { |