Added aliases with sizes for the integer and floating-point numbers
This commit is contained in:
1 parent
45f6021f82
commit
5e6211c2a9
14 files changed
+146
-136
No files matched your search
+20
-23
@@ -7,8 +7,8 @@
|
||||
#include "SDL_pixels.h"
|
||||
#include "Window.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <aliases.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -24,12 +24,12 @@ extern "C" {
|
||||
*/
|
||||
bool init_engine(const char *game_name, WindowSize window_size,
|
||||
SDL_Color window_background_color, bool full_screen,
|
||||
uint8_t audio_tracks);
|
||||
u8 audio_tracks);
|
||||
|
||||
bool game_running();
|
||||
void close_engine();
|
||||
|
||||
int64_t get_time();
|
||||
i64 get_time();
|
||||
// END GENERAL ENGINE API
|
||||
|
||||
// ASSET MANAGEMENT API
|
||||
@@ -75,40 +75,37 @@ void clip_render_rects_to_drawing_area(RenderRect *src, RenderRect *dest);
|
||||
RenderRect get_texture_asset_rect(AssetID id);
|
||||
void render_texture_asset(AssetID id, RenderRect *src, RenderRect *dest);
|
||||
TextSize get_text_size_from_font_asset(AssetID id, const char *text);
|
||||
void render_text_with_font_asset(AssetID id, const char *text, float x, float y,
|
||||
void render_text_with_font_asset(AssetID id, const char *text, f32 x, f32 y,
|
||||
SDL_Color color);
|
||||
void set_font_asset_size(AssetID id, uint32_t size);
|
||||
void set_font_asset_size(AssetID id, u32 size);
|
||||
// END RENDERING API
|
||||
|
||||
// AUDIO API
|
||||
int8_t play_audio_asset(AssetID id, int16_t loops, bool fade_in,
|
||||
uint32_t fade_length_in_ms);
|
||||
void pause_audio_asset_on_track(AssetID id, uint8_t track);
|
||||
void resume_audio_asset_on_track(AssetID id, uint8_t track);
|
||||
void stop_audio_asset_on_track(AssetID id, uint8_t track);
|
||||
void fade_out_audio_asset_on_track(AssetID id, uint8_t track,
|
||||
uint32_t fade_length_in_ms);
|
||||
i8 play_audio_asset(AssetID id, i16 loops, bool fade_in, u32 fade_length_in_ms);
|
||||
void pause_audio_asset_on_track(AssetID id, u8 track);
|
||||
void resume_audio_asset_on_track(AssetID id, u8 track);
|
||||
void stop_audio_asset_on_track(AssetID id, u8 track);
|
||||
void fade_out_audio_asset_on_track(AssetID id, u8 track, u32 fade_length_in_ms);
|
||||
void pause_all_instances_of_audio_asset(AssetID id);
|
||||
void resume_all_instances_of_audio_asset(AssetID id);
|
||||
void stop_all_instances_of_audio_asset(AssetID id);
|
||||
void fade_out_all_instances_of_audio_asset(AssetID id,
|
||||
uint32_t fade_length_in_ms);
|
||||
int8_t get_audio_asset_volume(AssetID id);
|
||||
void set_audio_asset_volume(AssetID id, int8_t volume);
|
||||
void play_music_asset(AssetID id, int16_t loops, bool fade_in,
|
||||
uint32_t fade_length_in_ms);
|
||||
void fade_out_all_instances_of_audio_asset(AssetID id, u32 fade_length_in_ms);
|
||||
i8 get_audio_asset_volume(AssetID id);
|
||||
void set_audio_asset_volume(AssetID id, i8 volume);
|
||||
void play_music_asset(AssetID id, i16 loops, bool fade_in,
|
||||
u32 fade_length_in_ms);
|
||||
void pause_music_asset(AssetID id);
|
||||
void resume_music_asset(AssetID id);
|
||||
void stop_music_asset(AssetID id);
|
||||
void fade_out_music_asset(AssetID id, uint32_t fade_length_in_ms);
|
||||
int8_t get_music_asset_volume(AssetID id);
|
||||
void set_music_asset_volume(AssetID id, int8_t volume);
|
||||
void fade_out_music_asset(AssetID id, u32 fade_length_in_ms);
|
||||
i8 get_music_asset_volume(AssetID id);
|
||||
void set_music_asset_volume(AssetID id, i8 volume);
|
||||
bool is_music_asset_playing(AssetID id);
|
||||
void pause_playing_music();
|
||||
void resume_playing_music();
|
||||
void stop_playing_music();
|
||||
void fade_out_playing_music(uint32_t fade_length_in_ms);
|
||||
void set_playing_music_volume(int8_t volume);
|
||||
void fade_out_playing_music(u32 fade_length_in_ms);
|
||||
void set_playing_music_volume(i8 volume);
|
||||
bool is_music_playing();
|
||||
// END AUDIO API
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@
|
||||
|
||||
#include "Renderer.h"
|
||||
#include "SDL_events.h"
|
||||
#include "aliases.h"
|
||||
#include "engine_build_config.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // !__cplusplus
|
||||
|
||||
typedef void (*EventHandlerPtr)(void *object, const SDL_Event *event);
|
||||
typedef void (*UpdateFuncPtr)(void *object, float delta);
|
||||
typedef void (*UpdateFuncPtr)(void *object, f32 delta);
|
||||
typedef void (*RenderFuncPtr)(void *object);
|
||||
|
||||
typedef struct object_store ObjectStore;
|
||||
@@ -40,7 +40,7 @@ ObjectID add_object_to_store(ObjectStore *os, void *object, EventHandlerPtr eh,
|
||||
void remove_object_from_store(ObjectStore *os, ObjectID *id_ptr);
|
||||
|
||||
void handle_all_objects_events(ObjectStore *os, const SDL_Event *event);
|
||||
void update_all_objects(ObjectStore *os, float delta);
|
||||
void update_all_objects(ObjectStore *os, f32 delta);
|
||||
void render_all_objects(ObjectStore *os);
|
||||
|
||||
/**
|
||||
|
||||
+12
-12
@@ -6,8 +6,8 @@
|
||||
#include "SDL_render.h"
|
||||
#include "SDL_surface.h"
|
||||
#include "SDL_video.h"
|
||||
#include "aliases.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -16,15 +16,15 @@ extern "C" {
|
||||
typedef struct renderer Renderer;
|
||||
|
||||
typedef struct {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
i32 width;
|
||||
i32 height;
|
||||
} TextSize;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
float height;
|
||||
f32 x;
|
||||
f32 y;
|
||||
f32 width;
|
||||
f32 height;
|
||||
} RenderRect;
|
||||
|
||||
/**
|
||||
@@ -40,14 +40,14 @@ Renderer *create_renderer(SDL_Window *window);
|
||||
* Useful when rendering on screens that support high DPI since the drawable
|
||||
* area is usually bigger than the user-defined size.
|
||||
*/
|
||||
void get_render_output_size(Renderer *renderer, int32_t *w, int32_t *h);
|
||||
void get_render_output_size(Renderer *renderer, i32 *w, i32 *h);
|
||||
|
||||
void set_render_draw_color(const Renderer *renderer, SDL_Color color);
|
||||
void render_clear(const Renderer *renderer, SDL_Color color);
|
||||
void draw_rect(const Renderer *renderer, SDL_Color color, float x, float y,
|
||||
float w, float h);
|
||||
void fill_rect(const Renderer *renderer, SDL_Color color, float x, float y,
|
||||
float w, float h);
|
||||
void draw_rect(const Renderer *renderer, SDL_Color color, f32 x, f32 y, f32 w,
|
||||
f32 h);
|
||||
void fill_rect(const Renderer *renderer, SDL_Color color, f32 x, f32 y, f32 w,
|
||||
f32 h);
|
||||
void render_surface(const Renderer *renderer, SDL_Surface *surface,
|
||||
const RenderRect *dest);
|
||||
void render_texture(const Renderer *renderer, SDL_Texture *texture,
|
||||
|
||||
+6
-7
@@ -5,22 +5,21 @@
|
||||
#include "SDL.h"
|
||||
#include "SDL_pixels.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // !__cplusplus
|
||||
|
||||
typedef struct window_size {
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
i32 width;
|
||||
i32 height;
|
||||
} WindowSize;
|
||||
|
||||
typedef struct drawing_area {
|
||||
float x;
|
||||
float y;
|
||||
float width;
|
||||
float height;
|
||||
f32 x;
|
||||
f32 y;
|
||||
f32 width;
|
||||
f32 height;
|
||||
} WindowDrawingArea;
|
||||
|
||||
typedef struct window {
|
||||
|
||||
@@ -1,12 +1,27 @@
|
||||
#ifndef ALIASES_H
|
||||
#define ALIASES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // !__cplusplus
|
||||
|
||||
#define INTERNAL static
|
||||
|
||||
#define i8 int8_t
|
||||
#define i16 int16_t
|
||||
#define i32 int32_t
|
||||
#define i64 int64_t
|
||||
|
||||
#define u8 uint8_t
|
||||
#define u16 uint16_t
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#define f32 float
|
||||
#define f64 double
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif // !__cplusplus
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#ifndef MATH_UTILS_H
|
||||
#define MATH_UTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include "aliases.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif // !__cplusplus
|
||||
|
||||
int32_t max_int(int32_t a, int32_t b);
|
||||
int32_t min_int(int32_t a, int32_t b);
|
||||
i32 max_int(i32 a, i32 b);
|
||||
i32 min_int(i32 a, i32 b);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#ifndef REUSABLE_IDS_H
|
||||
#define REUSABLE_IDS_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "aliases.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -10,10 +9,10 @@ extern "C" {
|
||||
|
||||
#define INVALID_ID -1
|
||||
|
||||
typedef int32_t ObjectID;
|
||||
typedef int32_t AssetID;
|
||||
typedef i32 ObjectID;
|
||||
typedef i32 AssetID;
|
||||
|
||||
int32_t reuse_id(int32_t *ids, size_t count);
|
||||
i32 reuse_id(i32 *ids, u64 count);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user