More assertions.
This commit is contained in:
@@ -11,6 +11,9 @@ tilesetdiv_t * bitmapFontGetCharacterDivision(tileset_t *tileset,
|
||||
char character
|
||||
) {
|
||||
int32_t i = ((int32_t)character) - BITMAP_FONT_CHAR_START;
|
||||
|
||||
ASSERT_NOT_NULL(tileset);
|
||||
|
||||
return tileset->divisions + i;
|
||||
}
|
||||
|
||||
@@ -24,6 +27,10 @@ bitmapfontmeasure_t bitmapFontMeasure(char *string,
|
||||
.height = 0, .lines = 1, .width = 0
|
||||
};
|
||||
|
||||
ASSERT_NOT_NULL(string);
|
||||
ASSERT_GREATER_THAN(charWidth, 0);
|
||||
ASSERT_GREATER_THAN(charHeight, 0);
|
||||
|
||||
i = 0;
|
||||
y = 0;
|
||||
x = 0;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../assert/assert.h"
|
||||
#include "spritebatch.h"
|
||||
#include "tileset.h"
|
||||
#include "../util/math.h"
|
||||
|
||||
@@ -11,11 +11,13 @@ void cameraLookAt(camera_t *camera,
|
||||
float x, float y, float z,
|
||||
float targetX, float targetY, float targetZ
|
||||
) {
|
||||
ASSERT_NOT_NULL(camera);
|
||||
matrixIdentity(&camera->view);
|
||||
matrixLookAt(&camera->view, x, y, z, targetX, targetY, targetZ, 0, 1, 0);
|
||||
}
|
||||
|
||||
void cameraLookAtStruct(camera_t *camera, cameralookat_t look) {
|
||||
ASSERT_NOT_NULL(camera);
|
||||
cameraLookAt(camera,
|
||||
look.x, look.y, look.z, look.lookX, look.lookY, look.lookZ
|
||||
);
|
||||
@@ -25,6 +27,8 @@ void cameraLook(camera_t *camera,
|
||||
float x, float y, float z,
|
||||
float pitch, float yaw, float roll
|
||||
) {
|
||||
ASSERT_NOT_NULL(camera);
|
||||
|
||||
matrixIdentity(&camera->view);
|
||||
matrixLook(&camera->view, x, y, z, pitch, yaw, roll, 0, 1, 0);
|
||||
}
|
||||
@@ -32,6 +36,8 @@ void cameraLook(camera_t *camera,
|
||||
void cameraPerspective(camera_t *camera,
|
||||
float fov, float aspect, float camNear, float camFar
|
||||
) {
|
||||
ASSERT_NOT_NULL(camera);
|
||||
|
||||
matrixIdentity(&camera->projection);
|
||||
matrixPerspective(&camera->projection,mathDeg2Rad(fov),aspect,camNear,camFar);
|
||||
}
|
||||
@@ -39,6 +45,8 @@ void cameraPerspective(camera_t *camera,
|
||||
void cameraOrtho(camera_t *camera,
|
||||
float left, float right, float bottom, float top, float camNear, float camFar
|
||||
) {
|
||||
ASSERT_NOT_NULL(camera);
|
||||
|
||||
matrixIdentity(&camera->projection);
|
||||
matrixOrtho(&camera->projection, left, right, bottom, top, camNear, camFar);
|
||||
}
|
||||
@@ -47,9 +55,13 @@ void cameraOrbit(camera_t *camera,
|
||||
float distance, float yaw, float pitch,
|
||||
float targetX, float targetY, float targetZ
|
||||
) {
|
||||
|
||||
float cy = cosf(pitch);
|
||||
float x = distance * sinf(yaw) * cy;
|
||||
float y = distance * sinf(pitch);
|
||||
float z = distance * cosf(yaw) * cy;
|
||||
|
||||
ASSERT_NOT_NULL(camera);
|
||||
|
||||
cameraLookAt(camera, x, y, z, targetX, targetY, targetZ);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../assert/assert.h"
|
||||
#include "../util/math.h"
|
||||
#include "matrix.h"
|
||||
|
||||
|
||||
@@ -32,10 +32,16 @@ void renderDispose() {
|
||||
}
|
||||
|
||||
void renderSetResolution(render_t *render, float width, float height) {
|
||||
ASSERT_NOT_NULL(render);
|
||||
ASSERT_GREATER_THAN(width, 0);
|
||||
ASSERT_GREATER_THAN(height, 0);
|
||||
|
||||
render->width = width;
|
||||
render->height = height;
|
||||
}
|
||||
|
||||
void renderResetFramebuffer(render_t *render) {
|
||||
ASSERT_NOT_NULL(render);
|
||||
|
||||
frameBufferUnbind(render->width, render->height, true);
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "../libs.h"
|
||||
#include "../assert/assert.h"
|
||||
#include "framebuffer.h"
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user