mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-22 02:19:44 +00:00
Merge branch 'main' into dev
This commit is contained in:
commit
5011a654be
7 changed files with 69 additions and 26 deletions
|
|
@ -1,4 +1,5 @@
|
|||
#include "graphics/core/Mesh.hpp"
|
||||
|
||||
int MeshStats::meshesCount = 0;
|
||||
int MeshStats::drawCalls = 0;
|
||||
int MeshStats::drawCalls = 0;
|
||||
int MeshStats::vertices = 0;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
struct MeshStats {
|
||||
static int meshesCount;
|
||||
static int drawCalls;
|
||||
static int vertices;
|
||||
};
|
||||
|
||||
struct IndexBufferData {
|
||||
|
|
|
|||
|
|
@ -118,17 +118,20 @@ void Mesh<VertexStructure>::draw(unsigned int primitive, int iboIndex) const {
|
|||
|
||||
if (!ibos.empty()) {
|
||||
if (iboIndex < ibos.size()) {
|
||||
size_t indexCount = ibos.at(iboIndex).indexCount;
|
||||
glBindVertexArray(vao);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibos[iboIndex].ibo);
|
||||
glDrawElements(
|
||||
primitive, ibos.at(iboIndex).indexCount, GL_UNSIGNED_INT, nullptr
|
||||
primitive, indexCount, GL_UNSIGNED_INT, nullptr
|
||||
);
|
||||
glBindVertexArray(0);
|
||||
MeshStats::vertices += indexCount;
|
||||
}
|
||||
} else if (vertexCount > 0) {
|
||||
glBindVertexArray(vao);
|
||||
glDrawArrays(primitive, 0, vertexCount);
|
||||
glBindVertexArray(0);
|
||||
MeshStats::vertices += vertexCount;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue