More assertions.
This commit is contained in:
@ -43,6 +43,7 @@ int32_t main() {
|
||||
|
||||
// Prepare the game
|
||||
game = malloc(sizeof(game_t));
|
||||
ASSERT_NOT_NULL(game);
|
||||
GAME_STATE = game;
|
||||
input = &game->engine.input;
|
||||
|
||||
@ -72,9 +73,6 @@ int32_t main() {
|
||||
inputBind(input, INPUT_MOUSE_X, GLFW_PLATFORM_INPUT_MOUSE_X);
|
||||
inputBind(input, INPUT_MOUSE_Y, GLFW_PLATFORM_INPUT_MOUSE_Y);
|
||||
|
||||
// Set up the client
|
||||
game->engine.client.setTitle = &glfwClientSetTitle;
|
||||
|
||||
// Set up some GLFW stuff
|
||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
glfwSetWindowTitle(window, game->engine.name);
|
||||
@ -112,13 +110,20 @@ int32_t main() {
|
||||
}
|
||||
|
||||
void glfwOnResize(GLFWwindow *window, int32_t width, int32_t height) {
|
||||
ASSERT_NOT_NULL(window);
|
||||
ASSERT_GREATER_THAN(width, 0);
|
||||
ASSERT_GREATER_THAN(height, 0);
|
||||
|
||||
renderSetResolution(&GAME_STATE->engine.render, (float)width, (float)height);
|
||||
}
|
||||
|
||||
void glfwOnKey(GLFWwindow *window,
|
||||
int32_t key, int32_t scancode, int32_t action, int32_t mods
|
||||
) {
|
||||
input_t *input = &GAME_STATE->engine.input;
|
||||
input_t *input;
|
||||
ASSERT_NOT_NULL(window);
|
||||
|
||||
input = &GAME_STATE->engine.input;
|
||||
if(action == GLFW_PRESS) {
|
||||
inputStateSet(input, glfwGetInputSourceForKey(key), 1.0f);
|
||||
} else if(action == GLFW_RELEASE) {
|
||||
@ -131,7 +136,10 @@ void glfwOnError(int error, const char* description) {
|
||||
}
|
||||
|
||||
void glfwOnCursor(GLFWwindow *window, double x, double y) {
|
||||
input_t *input = &GAME_STATE->engine.input;
|
||||
input_t *input;
|
||||
ASSERT_NOT_NULL(window);
|
||||
|
||||
input = &GAME_STATE->engine.input;
|
||||
inputStateSet(input, GLFW_PLATFORM_INPUT_MOUSE_X, (float)x);
|
||||
inputStateSet(input, GLFW_PLATFORM_INPUT_MOUSE_Y, (float)y);
|
||||
}
|
||||
@ -145,5 +153,6 @@ inputsource_t glfwGetInputSourceForKey(int32_t key) {
|
||||
}
|
||||
|
||||
void glfwClientSetTitle(char *name) {
|
||||
ASSERT_NOT_NULL(window);
|
||||
glfwSetWindowTitle(window, name);
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <libs.h>
|
||||
#include "display/render.h"
|
||||
#include "assert/assert.h"
|
||||
#include "input/input.h"
|
||||
#include "game/game.h"
|
||||
|
||||
|
Reference in New Issue
Block a user