Added reasons to assertions

This commit is contained in:
2023-07-23 10:15:37 -07:00
parent ef6b269141
commit 5b01eb904d
78 changed files with 357 additions and 289 deletions

View File

@ -73,7 +73,11 @@ void Mesh::disposeBuffers() {
}
void Mesh::bufferPositions(int32_t pos, glm::vec3 *positions, int32_t len) {
assertNotNull(positions);
assertNotNull(positions, "Mesh::bufferPositions: Positions cannot be null");
assertTrue(pos >= 0 && pos < this->verticeCount, "Mesh::bufferPositions: Position must be within range");
assertTrue(pos+len <= this->verticeCount, "Mesh::bufferPositions: Position + Length must be within range");
assertTrue(len > 0, "Mesh::bufferPositions: Length must be greater than zero");
glBindBuffer(GL_ARRAY_BUFFER, this->vertexBuffer);
glBufferSubData(
GL_ARRAY_BUFFER,
@ -84,7 +88,10 @@ void Mesh::bufferPositions(int32_t pos, glm::vec3 *positions, int32_t len) {
}
void Mesh::bufferCoordinates(int32_t pos, glm::vec2 *coordinates, int32_t len) {
assertNotNull(coordinates);
assertNotNull(coordinates, "Mesh::bufferCoordinates: Coordinates cannot be null");
assertTrue(pos >= 0 && pos < this->verticeCount, "Mesh::bufferCoordinates: Position must be within range");
assertTrue(pos+len <= this->verticeCount, "Mesh::bufferCoordinates: Position + Length must be within range");
assertTrue(len > 0, "Mesh::bufferCoordinates: Length must be greater than zero");
auto offsetCoordinates = (
(sizeof(glm::vec3) * this->verticeCount) +
@ -101,7 +108,11 @@ void Mesh::bufferCoordinates(int32_t pos, glm::vec2 *coordinates, int32_t len) {
}
void Mesh::bufferIndices(int32_t pos, meshindice_t *indices, int32_t len) {
assertNotNull(indices);
assertNotNull(indices, "Mesh::bufferIndices: Indices cannot be null");
assertTrue(pos >= 0 && pos < this->indiceCount, "Mesh::bufferIndices: Position must be within range");
assertTrue(pos+len <= this->indiceCount, "Mesh::bufferIndices: Position + Length must be within range");
assertTrue(len > 0, "Mesh::bufferIndices: Length must be greater than zero");
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, this->indexBuffer);
glBufferSubData(
GL_ELEMENT_ARRAY_BUFFER,