Writing a few more asserts.

This commit is contained in:
2022-01-03 08:12:28 -08:00
parent 44ecc307e6
commit 0ff8548e15
9 changed files with 98 additions and 1 deletions

View File

@ -16,6 +16,10 @@
void textureInit(texture_t *texture, int32_t width, int32_t height,
pixel_t *pixels
) {
ASSERT_NOT_NULL(texture);
ASSERT_GREATER_THAN(width, 0);
ASSERT_GREATER_THAN(height, 0);
texture->width = width;
texture->height = height;
@ -50,6 +54,10 @@ void textureInit(texture_t *texture, int32_t width, int32_t height,
}
void textureBind(texture_t *texture, textureslot_t slot) {
ASSERT_NOT_NULL(texture);
ASSERT_GREATER_THAN_EQUAL_TO(slot, 0);
ASSERT_LESS_THAN(slot, TEXTURE_SLOTS_MAX);
glActiveTexture(GL_TEXTURE0 + slot);
glBindTexture(GL_TEXTURE_2D, texture->id);
}
@ -57,6 +65,15 @@ void textureBind(texture_t *texture, textureslot_t slot) {
void textureBufferPixels(texture_t *texture,
int32_t x, int32_t y, int32_t width, int32_t height, pixel_t *pixels
) {
ASSERT_NOT_NULL(texture);
ASSERT_NOT_NULL(pixels);
ASSERT_GREATER_THAN_EQUAL_TO(x, 0);
ASSERT_GREATER_THAN_EQUAL_TO(y, 0);
ASSERT_GREATER_THAN(width, 0);
ASSERT_GREATER_THAN(height, 0);
ASSERT_LESS_THAN_EQUAL_TO(width, texture->width);
ASSERT_LESS_THAN_EQUAL_TO(height, texture->height);
glBindTexture(GL_TEXTURE_2D, texture->id);
glTexSubImage2D(GL_TEXTURE_2D, 0,
x, y, width, height,
@ -65,5 +82,6 @@ void textureBufferPixels(texture_t *texture,
}
void textureDispose(texture_t *texture) {
ASSERT_NOT_NULL(texture);
glDeleteTextures(1, &texture->id);
}