1
0
Fork 0
2022-untitled-game/code/game/common.h

81 lines
1.7 KiB
C

#pragma once
// System
#include <assert.h>
#include <float.h>
#include <math.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
// 3rd Party
#include <glad/gl.h>
#include <SDL.h>
const char* WINDOW_TITLE = "Untitled Game";
const int TARGET_FRAME_TIME = 16;
const int WINDOW_WIDTH = 1280;
const int WINDOW_HEIGHT = 960;
const int RENDER_WIDTH = 320;
const int RENDER_HEIGHT = 240;
const size_t ENGINE_MEMORY_SIZE = 1U * 1024U * 1024U;
const size_t GAME_MEMORY_SIZE = 1U * 1024U * 1024U;
const size_t DATA1_MEMORY_SIZE = 8U * 1024U * 1024U;
const size_t DATA2_MEMORY_SIZE = 8U * 1024U * 1024U;
const size_t SCRATCH_MEMORY_SIZE = 1U * 1024U * 1024U;
#ifdef BUILD_DEBUG
const size_t DEBUG_MEMORY_SIZE = 1U * 1024U * 1024U;
#endif
const float VIEWPORT_WIDTH = (float)RENDER_WIDTH * WINDOW_HEIGHT / RENDER_HEIGHT;
const float VIEWPORT_HEIGHT = (float)RENDER_HEIGHT * WINDOW_HEIGHT / RENDER_HEIGHT;
const float VIEWPORT_X = WINDOW_WIDTH/2 - VIEWPORT_WIDTH/2;
const float VIEWPORT_Y = WINDOW_HEIGHT/2 - VIEWPORT_HEIGHT/2;
typedef struct input {
bool forward; bool backward;
bool strafe_left; bool strafe_right;
bool up; bool down;
bool left; bool right;
bool select;
bool interact;
bool pause;
int mouse_x_delta;
int mouse_y_delta;
#ifdef BUILD_DEBUG
struct {
bool enable;
bool speed;
bool up;
bool down;
} debug;
#endif
} input_t;
typedef struct memory_region {
void* begin;
void* current;
void* end;
} memory_region_t;
typedef struct memory {
memory_region_t engine;
memory_region_t game;
memory_region_t data1;
memory_region_t data2;
memory_region_t scratch;
#ifdef BUILD_DEBUG
memory_region_t debug;
#endif
} memory_t;