twn_util.h: separate internal things away, remove indirect includes in places
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#ifndef TWN_CAMERA_H
|
||||
#define TWN_CAMERA_H
|
||||
|
||||
#include "twn_util.h"
|
||||
#include "twn_types.h"
|
||||
#include "twn_engine_api.h"
|
||||
|
||||
/* TODO: make it cached? */
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef TWN_CONTEXT_H
|
||||
#define TWN_CONTEXT_H
|
||||
|
||||
#include "twn_input.h"
|
||||
#include "twn_types.h"
|
||||
#include "twn_engine_api.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef TWN_DRAW_H
|
||||
#define TWN_DRAW_H
|
||||
|
||||
#include "twn_util.h"
|
||||
#include "twn_types.h"
|
||||
#include "twn_option.h"
|
||||
#include "twn_camera.h"
|
||||
#include "twn_engine_api.h"
|
||||
|
@ -2,21 +2,22 @@
|
||||
#ifndef TWN_GAME_API_H
|
||||
#define TWN_GAME_API_H
|
||||
|
||||
|
||||
#include "twn_input.h"
|
||||
#include "twn_context.h"
|
||||
#include "twn_draw.h"
|
||||
#include "twn_audio.h"
|
||||
#include "twn_util.h"
|
||||
#include "twn_input.h"
|
||||
#include "twn_engine_api.h"
|
||||
#include "twn_util.h"
|
||||
|
||||
#ifndef TWN_NOT_C
|
||||
|
||||
/* sole game logic and display function.
|
||||
all state must be used from and saved to supplied state pointer. */
|
||||
TWN_API extern void game_tick(void);
|
||||
|
||||
/* called when application is closing. */
|
||||
TWN_API extern void game_end(void);
|
||||
/* sole game logic and display function.
|
||||
all state must be used from and saved to supplied state pointer. */
|
||||
TWN_API extern void game_tick(void);
|
||||
|
||||
/* called when application is closing. */
|
||||
TWN_API extern void game_end(void);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -3,21 +3,13 @@
|
||||
|
||||
#include "twn_types.h"
|
||||
#include "twn_engine_api.h"
|
||||
#include "twn_types.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
|
||||
/* DON'T FORGET ABOUT DOUBLE EVALUATION */
|
||||
/* YOU THINK YOU WON'T, AND THEN YOU DO */
|
||||
/* C23's typeof could fix it, so i will */
|
||||
/* leave them as macros to be replaced. */
|
||||
/* use the macro in tgmath.h for floats */
|
||||
#define MAX SDL_max
|
||||
#define MIN SDL_min
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338327950288 /**< pi */
|
||||
#endif
|
||||
@ -26,16 +18,13 @@
|
||||
#define DEG2RAD (M_PI / 180)
|
||||
#define RAD2DEG (180 / M_PI)
|
||||
|
||||
#ifndef TWN_NOT_C
|
||||
|
||||
/* */
|
||||
/* GENERAL UTILITIES */
|
||||
/* */
|
||||
TWN_API void *cmalloc(size_t size);
|
||||
TWN_API void *crealloc(void *ptr, size_t size);
|
||||
TWN_API void *ccalloc(size_t num, size_t size);
|
||||
|
||||
TWN_API void cry_impl(const char *file, const int line, const char *title, const char *text);
|
||||
#define CRY(title, text) cry_impl(__FILE__, __LINE__, title, text)
|
||||
#define CRY_SDL(title) cry_impl(__FILE__, __LINE__, title, SDL_GetError())
|
||||
#define CRY_PHYSFS(title) \
|
||||
cry_impl(__FILE__, __LINE__, title, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()))
|
||||
#endif /* TWN_NOT_C */
|
||||
|
||||
|
||||
TWN_API void log_info(const char *restrict format, ...);
|
||||
@ -43,18 +32,6 @@ TWN_API void log_critical(const char *restrict format, ...);
|
||||
TWN_API void log_warn(const char *restrict format, ...);
|
||||
|
||||
|
||||
/* for when there's absolutely no way to continue */
|
||||
TWN_API _Noreturn void die_abruptly(void);
|
||||
|
||||
|
||||
/* "critical" allocation functions which will log and abort() on failure. */
|
||||
/* if it is reasonable to handle this gracefully, use the standard versions. */
|
||||
/* the stb implementations will be configured to use these */
|
||||
TWN_API void *cmalloc(size_t size);
|
||||
TWN_API void *crealloc(void *ptr, size_t size);
|
||||
TWN_API void *ccalloc(size_t num, size_t size);
|
||||
|
||||
|
||||
/* TODO: this is why generics were invented. sorry, i'm tired today */
|
||||
TWN_API double clamp(double d, double min, double max);
|
||||
TWN_API float clampf(float f, float min, float max);
|
||||
|
Reference in New Issue
Block a user