summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/rodeo/audio.h21
-rw-r--r--include/rodeo/audio_t.h16
-rw-r--r--include/rodeo/collision.h4
-rw-r--r--include/rodeo/collision_t.h10
-rw-r--r--include/rodeo/gfx.h16
-rw-r--r--include/rodeo/input.h36
-rw-r--r--include/rodeo/input_t.h29
-rw-r--r--src/audio/irodeo_audio_t.h (renamed from src/audio/rodeo_audio_t.h)7
-rw-r--r--src/audio/rodeo_audio.c45
-rw-r--r--src/collision/rodeo_collision.c38
-rw-r--r--src/gfx/rodeo_gfx.c82
-rw-r--r--src/input/irodeo_input_t.h4
-rw-r--r--src/input/rodeo_input.c149
13 files changed, 241 insertions, 216 deletions
diff --git a/include/rodeo/audio.h b/include/rodeo/audio.h
index 14ae6f0..092e7f5 100644
--- a/include/rodeo/audio.h
+++ b/include/rodeo/audio.h
@@ -1,14 +1,15 @@
#pragma once
+// -- internal --
+// public
+#include "rodeo/audio_t.h"
+
// -- external --
#include "stc/cstr.h"
// -- system --
#include <inttypes.h>
-typedef struct rodeo_audio_sound_t rodeo_audio_sound_t;
-typedef struct rodeo_audio_music_t rodeo_audio_music_t;
-
void
rodeo_audio_init(
uint32_t channels
@@ -52,26 +53,26 @@ float
rodeo_audio_channelPool_volume_get(uint32_t channel_pool_id);
*/
-rodeo_audio_sound_t*
+rodeo_audio_sound_t
rodeo_audio_sound_create_from_path(cstr path);
void
-rodeo_audio_sound_destroy(rodeo_audio_sound_t* sound);
+rodeo_audio_sound_destroy(rodeo_audio_sound_t sound);
-rodeo_audio_music_t*
+rodeo_audio_music_t
rodeo_audio_music_create_from_path(cstr path);
void
-rodeo_audio_music_destroy(rodeo_audio_music_t* music);
+rodeo_audio_music_destroy(rodeo_audio_music_t music);
void
-rodeo_audio_sound_play(rodeo_audio_sound_t *sound);
+rodeo_audio_sound_play(rodeo_audio_sound_t sound);
void
-rodeo_audio_music_play(rodeo_audio_music_t *music);
+rodeo_audio_music_play(rodeo_audio_music_t music);
void
-rodeo_audio_music_play_fadeIn(rodeo_audio_music_t *music, uint32_t fade_duration_milliseconds);
+rodeo_audio_music_play_fadeIn(rodeo_audio_music_t music, uint32_t fade_duration_milliseconds);
void
rodeo_audio_music_stop(void);
diff --git a/include/rodeo/audio_t.h b/include/rodeo/audio_t.h
index 45dcbb0..561229a 100644
--- a/include/rodeo/audio_t.h
+++ b/include/rodeo/audio_t.h
@@ -1,3 +1,19 @@
#pragma once
+typedef struct rodeo_audio_sound_data rodeo_audio_sound_data_t;
+typedef
+struct
+{
+ rodeo_audio_sound_data_t *data;
+}
+rodeo_audio_sound_t;
+
+typedef struct rodeo_audio_music_data rodeo_audio_music_data_t;
+
+typedef
+struct
+{
+ rodeo_audio_music_data_t *data;
+}
+rodeo_audio_music_t;
diff --git a/include/rodeo/collision.h b/include/rodeo/collision.h
index 365522c..b3619f4 100644
--- a/include/rodeo/collision.h
+++ b/include/rodeo/collision.h
@@ -55,6 +55,6 @@ rodeo_collision_2d_world_compare_other(
// from raylib GetCollisionRect
rodeo_rectangle_t
rodeo_collision_2d_get_collision_rect(
- rodeo_collision_2d_world_item_t *a,
- rodeo_collision_2d_world_item_t *b
+ rodeo_rectangle_t a,
+ rodeo_rectangle_t b
);
diff --git a/include/rodeo/collision_t.h b/include/rodeo/collision_t.h
index e75d243..21ffbf4 100644
--- a/include/rodeo/collision_t.h
+++ b/include/rodeo/collision_t.h
@@ -1,5 +1,9 @@
#pragma once
+// -- internal --
+// public
+#include "rodeo_types.h"
+
// -- system --
#include <stdint.h>
#include <stdbool.h>
@@ -17,13 +21,9 @@ typedef
struct
{
world_id id;
- float x;
- float y;
+ rodeo_rectangle_t rect;
float dx;
float dy;
- bool is_circle;
- float width;
- float height;
}
rodeo_collision_2d_world_item_t;
diff --git a/include/rodeo/gfx.h b/include/rodeo/gfx.h
index 28d46ff..a10e901 100644
--- a/include/rodeo/gfx.h
+++ b/include/rodeo/gfx.h
@@ -25,7 +25,7 @@ rodeo_gfx_renderer_name_get(void);
void
rodeo_gfx_renderer_flush(void);
-const rodeo_gfx_texture_2d_t*
+rodeo_gfx_texture_2d_t
rodeo_gfx_texture_2d_default_get(void);
rodeo_gfx_texture_2d_t
@@ -39,20 +39,20 @@ rodeo_gfx_texture_2d_t
rodeo_gfx_texture_2d_create_from_path(cstr path);
void
-rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t *texture);
+rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t texture);
void
rodeo_gfx_rectangle_draw(
- const rodeo_rectangle_t *rectangle,
- const rodeo_color_RGBAFloat_t *color
+ const rodeo_rectangle_t rectangle,
+ const rodeo_color_RGBAFloat_t color
);
void
rodeo_gfx_texture_2d_draw(
- const rodeo_rectangle_t *destination,
- const rodeo_rectangle_t *source,
- const rodeo_color_RGBAFloat_t *color,
- const rodeo_gfx_texture_2d_t *texture
+ const rodeo_rectangle_t destination,
+ const rodeo_rectangle_t source,
+ const rodeo_color_RGBAFloat_t color,
+ const rodeo_gfx_texture_2d_t texture
);
void
diff --git a/include/rodeo/input.h b/include/rodeo/input.h
index fe2b67d..dac70e9 100644
--- a/include/rodeo/input.h
+++ b/include/rodeo/input.h
@@ -8,64 +8,64 @@ rodeo_input_poll(void);
void
rodeo_input_command_register_callback(
- rodeo_input_command_t *command,
+ rodeo_input_command_t command,
rodeo_input_callback_function func
);
void
rodeo_input_command_unregister_callback(
- rodeo_input_command_t *command,
+ rodeo_input_command_t command,
rodeo_input_callback_function func
);
-rodeo_input_scene_t*
+rodeo_input_scene_t
rodeo_input_scene_create(void);
void
-rodeo_input_scene_destroy(rodeo_input_scene_t *scene);
+rodeo_input_scene_destroy(rodeo_input_scene_t scene);
-rodeo_input_command_t*
+rodeo_input_command_t
rodeo_input_command_create(uint32_t input_types);
// make sure to unregister from all scenes before destroying
void
-rodeo_input_command_destroy(rodeo_input_command_t *command);
+rodeo_input_command_destroy(rodeo_input_command_t command);
// returns false if attempting to register
// input type that has been set as valid
bool
rodeo_input_command_register_binary_scancode(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_scancode_t scancode
);
bool
rodeo_input_command_register_binary_controllerButton(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_controllerButton_t button
);
bool
rodeo_input_command_register_binary_mouseButton(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_mouseButton_t mouse_button
);
bool
rodeo_input_command_register_positional_mouse(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_positional_mouse_t mouse_axis
);
bool
rodeo_input_command_register_boundedRange_controllerAxis(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_boundedRange_controllerAxis_t controller_axis
);
bool
rodeo_input_command_register_unboundedRange_mouse(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_unboundedRange_mouse_t mouse_axis
);
@@ -75,24 +75,24 @@ rodeo_input_command_register_unboundedRange_mouse(
void
rodeo_input_scene_register_command(
- rodeo_input_scene_t *scene,
- rodeo_input_command_t *command
+ rodeo_input_scene_t scene,
+ rodeo_input_command_t command
);
void
rodeo_input_scene_unregister_command(
- rodeo_input_scene_t *scene,
- rodeo_input_command_t *command
+ rodeo_input_scene_t scene,
+ rodeo_input_command_t command
);
void
rodeo_input_scene_activate(
- rodeo_input_scene_t *scene
+ rodeo_input_scene_t scene
);
void
rodeo_input_scene_deactivate(
- rodeo_input_scene_t *scene
+ rodeo_input_scene_t scene
);
void
diff --git a/include/rodeo/input_t.h b/include/rodeo/input_t.h
index 90ab71d..4903b54 100644
--- a/include/rodeo/input_t.h
+++ b/include/rodeo/input_t.h
@@ -764,7 +764,8 @@ enum
}
rodeo_input_binary_mouseButton_t;
-typedef enum
+typedef
+enum
{
rodeo_input_binary_controllerButton_INVALID = -1,
rodeo_input_binary_controllerButton_A,
@@ -927,7 +928,7 @@ void*
#include <stc/cset.h>
#define i_val rodeo_input_boundedRange_controllerAxis_t
-#define i_tag input_boundedRange_controllerAxis
+#define i_tag input_boundedRange_controllerAxes
#include <stc/cset.h>
#define i_val rodeo_input_unboundedRange_mouse_t
@@ -935,7 +936,7 @@ void*
#include <stc/cset.h>
#define i_val rodeo_input_binary_controllerButton_t
-#define i_tag input_binary_controllerButton
+#define i_tag input_binary_controllerButtons
#include <stc/cset.h>
typedef
@@ -949,7 +950,7 @@ struct
{
cset_input_binary_scancodes scancodes;
cset_input_binary_mouseButtons mouse_buttons;
- cset_input_binary_controllerButton controller_buttons;
+ cset_input_binary_controllerButtons controller_buttons;
}
binary;
@@ -961,7 +962,7 @@ struct
struct
{
- cset_input_boundedRange_controllerAxis controller_axes;
+ cset_input_boundedRange_controllerAxes controller_axes;
}
bounded_range;
@@ -972,9 +973,17 @@ struct
unbounded_range;
}
+rodeo_input_command_data_t;
+
+
+typedef
+struct
+{
+ rodeo_input_command_data_t *data;
+}
rodeo_input_command_t;
-#define i_val rodeo_input_command_t*
+#define i_val rodeo_input_command_data_t*
#define i_tag input_commands
#include <stc/cset.h>
@@ -983,4 +992,12 @@ struct
{
cset_input_commands commands;
}
+rodeo_input_scene_data_t;
+
+
+typedef
+struct
+{
+ rodeo_input_scene_data_t *data;
+}
rodeo_input_scene_t;
diff --git a/src/audio/rodeo_audio_t.h b/src/audio/irodeo_audio_t.h
index b762cf3..e2e247e 100644
--- a/src/audio/rodeo_audio_t.h
+++ b/src/audio/irodeo_audio_t.h
@@ -1,16 +1,15 @@
#pragma once
+
// -- external --
-#include "SDL.h"
#include "SDL_mixer.h"
struct
-rodeo_audio_sound_t
+rodeo_audio_sound_data
{
Mix_Chunk *sdl_sound;
};
-
struct
-rodeo_audio_music_t
+rodeo_audio_music_data
{
Mix_Music *sdl_music;
};
diff --git a/src/audio/rodeo_audio.c b/src/audio/rodeo_audio.c
index f049fa2..485ddfd 100644
--- a/src/audio/rodeo_audio.c
+++ b/src/audio/rodeo_audio.c
@@ -4,13 +4,13 @@
#include "rodeo/audio.h"
#include "rodeo/log.h"
// private
-#include "audio/rodeo_audio_t.h"
+#include "audio/irodeo_audio_t.h"
// -- external --
#include "SDL.h"
#include "SDL_mixer.h"
-static uint32_t **irodeo_audio_channelPool;
+//static uint32_t **irodeo_audio_channelPool;
//static uint32_t irodeo_audio_channelPool_num;
//static uint32_t irodeo_audio_channelPool_size;
@@ -92,7 +92,7 @@ rodeo_audio_init(uint32_t channels)
void
rodeo_audio_deinit(void)
{
- free(irodeo_audio_channelPool);
+ //free(irodeo_audio_channelPool);
Mix_Quit();
}
@@ -147,12 +147,13 @@ rodeo_audio_channelPool_volume_get(uint32_t channel_pool_id)
}
*/
-rodeo_audio_sound_t*
+rodeo_audio_sound_t
rodeo_audio_sound_create_from_path(cstr path)
{
- rodeo_audio_sound_t *sample_sound = malloc(sizeof(rodeo_audio_sound_t));
- sample_sound->sdl_sound = Mix_LoadWAV(cstr_str(&path));
- if(NULL == sample_sound->sdl_sound)
+ rodeo_audio_sound_t sample_sound = {0};
+ sample_sound.data = calloc(1, sizeof(*sample_sound.data));
+ sample_sound.data->sdl_sound = Mix_LoadWAV(cstr_str(&path));
+ if(NULL == sample_sound.data->sdl_sound)
{
rodeo_log(
rodeo_logLevel_error,
@@ -164,18 +165,17 @@ rodeo_audio_sound_create_from_path(cstr path)
}
void
-rodeo_audio_sound_destroy(rodeo_audio_sound_t* sound)
+rodeo_audio_sound_destroy(rodeo_audio_sound_t sound)
{
- Mix_FreeChunk(sound->sdl_sound);
- free(sound);
+ Mix_FreeChunk(sound.data->sdl_sound);
}
-rodeo_audio_music_t*
+rodeo_audio_music_t
rodeo_audio_music_create_from_path(cstr path)
{
- rodeo_audio_music_t *sample_music = malloc(sizeof(rodeo_audio_music_t));
- sample_music->sdl_music = Mix_LoadMUS(cstr_str(&path));
- if(NULL == sample_music->sdl_music)
+ rodeo_audio_music_t sample_music = {0};
+ sample_music.data->sdl_music = Mix_LoadMUS(cstr_str(&path));
+ if(NULL == sample_music.data->sdl_music)
{
rodeo_log(
rodeo_logLevel_error,
@@ -187,31 +187,30 @@ rodeo_audio_music_create_from_path(cstr path)
}
void
-rodeo_audio_music_destroy(rodeo_audio_music_t* music)
+rodeo_audio_music_destroy(rodeo_audio_music_t music)
{
- Mix_FreeMusic(music->sdl_music);
- free(music);
+ Mix_FreeMusic(music.data->sdl_music);
}
void
-rodeo_audio_sound_play(rodeo_audio_sound_t *sound) //, uint32_t channel_pool_id)
+rodeo_audio_sound_play(rodeo_audio_sound_t sound) //, uint32_t channel_pool_id)
{
- Mix_PlayChannel(-1, sound->sdl_sound, 0);
+ Mix_PlayChannel(-1, sound.data->sdl_sound, 0);
}
void
-rodeo_audio_music_play(rodeo_audio_music_t *music) //, uint32_t channel_pool_id)
+rodeo_audio_music_play(rodeo_audio_music_t music) //, uint32_t channel_pool_id)
{
rodeo_audio_music_stop();
- Mix_PlayMusic(music->sdl_music, 0);
+ Mix_PlayMusic(music.data->sdl_music, 0);
}
void
-rodeo_audio_music_play_fadeIn(rodeo_audio_music_t *music, uint32_t fade_duration_milliseconds)
+rodeo_audio_music_play_fadeIn(rodeo_audio_music_t music, uint32_t fade_duration_milliseconds)
{
rodeo_audio_music_stop();
- Mix_FadeInMusic(music->sdl_music, 0, (int32_t)fade_duration_milliseconds);
+ Mix_FadeInMusic(music.data->sdl_music, 0, (int32_t)fade_duration_milliseconds);
}
void
diff --git a/src/collision/rodeo_collision.c b/src/collision/rodeo_collision.c
index 95fc75c..d529e65 100644
--- a/src/collision/rodeo_collision.c
+++ b/src/collision/rodeo_collision.c
@@ -3,15 +3,15 @@
#include <stdio.h>
bool detect_collision(
- const rodeo_collision_2d_world_item_t *a,
- const rodeo_collision_2d_world_item_t *b
+ const rodeo_collision_2d_world_item_t a,
+ const rodeo_collision_2d_world_item_t b
)
{
- return !(a->id.id == b->id.id ||
- a->x+a->dx > b->x+b->dx + b->width ||
- b->x+b->dx > a->x+a->dx + a->width ||
- a->y+a->dy > b->y+b->dy + b->height ||
- b->y+b->dy > a->y+a->dy + a->height);
+ return !(a.id.id == b.id.id ||
+ a.rect.x+a.dx > b.rect.x+b.dx + b.rect.width ||
+ b.rect.x+b.dx > a.rect.x+a.dx + a.rect.width ||
+ a.rect.y+a.dy > b.rect.y+b.dy + b.rect.height ||
+ b.rect.y+b.dy > a.rect.y+a.dy + a.rect.height);
}
rodeo_collision_2d_world_t
@@ -90,7 +90,7 @@ rodeo_collision_2d_world_compare_self(
{
c_foreach(i, cvec_collision_2d_world_item, *world) {
c_foreach(j, cvec_collision_2d_world_item, cvec_collision_2d_world_item_advance(i, 1), cvec_collision_2d_world_item_end(world)) {
- if (detect_collision(i.ref, j.ref)) {
+ if (detect_collision(*i.ref, *j.ref)) {
resolve(i.ref, j.ref);
}
}
@@ -109,7 +109,7 @@ rodeo_collision_2d_world_compare_other(
{
c_foreach(i, cvec_collision_2d_world_item, *world_a) {
c_foreach(j, cvec_collision_2d_world_item, *world_b) {
- if (detect_collision(i.ref, j.ref)) {
+ if (detect_collision(*i.ref, *j.ref)) {
resolve(i.ref, j.ref);
}
}
@@ -132,20 +132,20 @@ int rodeo_collision_2d_item_cmp(
// from raylib GetCollisionRect
rodeo_rectangle_t
rodeo_collision_2d_get_collision_rect(
- rodeo_collision_2d_world_item_t *a,
- rodeo_collision_2d_world_item_t *b
+ rodeo_rectangle_t a,
+ rodeo_rectangle_t b
)
{
rodeo_rectangle_t overlap = { 0 };
- float left = (a->x > b->x)? a->x : b->x;
- float right1 = a->x + a->width;
- float right2 = b->x + b->width;
- float right = (right1 < right2)? right1 : right2;
- float top = (a->y > b->y)? a->y : b->y;
- float bottom1 = a->y + a->height;
- float bottom2 = b->y + b->height;
- float bottom = (bottom1 < bottom2)? bottom1 : bottom2;
+ float left = (a.x > b.x)? a.x : b.x;
+ float right_a = a.x + a.width;
+ float right_b = b.x + b.width;
+ float right = (right_a < right_b)? right_a : right_b;
+ float top = (a.y > b.y)? a.y : b.y;
+ float bottom_a = a.y + a.height;
+ float bottom_b = b.y + b.height;
+ float bottom = (bottom_a < bottom_b)? bottom_a : bottom_b;
if ((left < right) && (top < bottom))
{
diff --git a/src/gfx/rodeo_gfx.c b/src/gfx/rodeo_gfx.c
index eb77b27..04d923f 100644
--- a/src/gfx/rodeo_gfx.c
+++ b/src/gfx/rodeo_gfx.c
@@ -313,7 +313,7 @@ rodeo_gfx_renderer_flush(void)
bgfx_set_texture(
0,
irodeo_gfx_state.texture_uniforms[0],
- rodeo_gfx_texture_2d_default_get()->internal_texture->texture_bgfx,
+ rodeo_gfx_texture_2d_default_get().internal_texture->texture_bgfx,
UINT32_MAX
);
if(irodeo_gfx_state.active_texture_p != NULL)
@@ -332,7 +332,7 @@ rodeo_gfx_renderer_flush(void)
bgfx_set_texture(
1,
irodeo_gfx_state.texture_uniforms[1],
- rodeo_gfx_texture_2d_default_get()->internal_texture->texture_bgfx,
+ rodeo_gfx_texture_2d_default_get().internal_texture->texture_bgfx,
UINT32_MAX
);
}
@@ -375,10 +375,10 @@ rodeo_gfx_renderer_flush(void)
irodeo_gfx_state.active_texture_p = NULL;
}
-const rodeo_gfx_texture_2d_t*
+rodeo_gfx_texture_2d_t
rodeo_gfx_texture_2d_default_get(void)
{
- return &irodeo_gfx_state.default_texture;
+ return irodeo_gfx_state.default_texture;
}
rodeo_gfx_texture_2d_t
@@ -409,49 +409,49 @@ rodeo_gfx_texture_2d_create_from_RGBA8(
}
void
-rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t *texture)
+rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t texture)
{
- bgfx_destroy_texture(texture->internal_texture->texture_bgfx);
- free(texture->internal_texture);
+ bgfx_destroy_texture(texture.internal_texture->texture_bgfx);
+ free(texture.internal_texture);
}
void
rodeo_gfx_rectangle_draw(
- const rodeo_rectangle_t *rectangle,
- const rodeo_color_RGBAFloat_t *color
+ const rodeo_rectangle_t rectangle,
+ const rodeo_color_RGBAFloat_t color
)
{
rodeo_gfx_texture_2d_draw(
rectangle,
- NULL,
+ (rodeo_rectangle_t){ 0, 0, (float)rodeo_gfx_texture_2d_default_get().width, (float)rodeo_gfx_texture_2d_default_get().height },
color,
- NULL
+ rodeo_gfx_texture_2d_default_get()
);
}
void
rodeo_gfx_texture_2d_draw(
// cant be NULL
- const rodeo_rectangle_t *destination,
+ const rodeo_rectangle_t destination,
// default: entire texture
- const rodeo_rectangle_t *source,
+ const rodeo_rectangle_t source,
// default: white
- const rodeo_color_RGBAFloat_t *color,
+ const rodeo_color_RGBAFloat_t color,
// default: default texture
- const rodeo_gfx_texture_2d_t *texture
+ const rodeo_gfx_texture_2d_t texture
)
{
// whether to use default or custom texture
float texture_uniform_slot = 0.0;
rodeo_rectangle_t source_applied;
- if(source != NULL && texture != NULL)
+ if((source.height != 0 || source.width != 0) && texture.internal_texture != NULL)
{
source_applied = (rodeo_rectangle_t){
- .x = source->x / (float)texture->width,
- .y = source->y / (float)texture->height,
- .width = source->width / (float)texture->width,
- .height = source->height / (float)texture->height,
+ .x = source.x / (float)texture.width,
+ .y = source.y / (float)texture.height,
+ .width = source.width / (float)texture.width,
+ .height = source.height / (float)texture.height,
};
}
else
@@ -464,33 +464,21 @@ rodeo_gfx_texture_2d_draw(
};
}
- rodeo_color_RGBAFloat_t color_applied;
- if(color != NULL)
- {
- color_applied = *color;
- }
- else
- {
- color_applied = (rodeo_color_RGBAFloat_t){
- { 1.0f, 1.0f, 1.0f, 1.0f }
- };
- }
-
// if not using texture: use default instead
// otherwise check what current texture is active
// if none or the same: set it
// if different: flush and then set it
- if(texture != NULL)
+ if(texture.internal_texture != NULL)
{
if(irodeo_gfx_state.active_texture_p != NULL)
{
- if(&texture->internal_texture->texture_bgfx != irodeo_gfx_state.active_texture_p)
+ if(&texture.internal_texture->texture_bgfx != irodeo_gfx_state.active_texture_p)
{
rodeo_gfx_renderer_flush();
}
}
texture_uniform_slot = 1.0;
- irodeo_gfx_state.active_texture_p = &texture->internal_texture->texture_bgfx;
+ irodeo_gfx_state.active_texture_p = &texture.internal_texture->texture_bgfx;
}
@@ -499,10 +487,10 @@ rodeo_gfx_texture_2d_draw(
irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] =
(rodeo_gfx_vertex_t)
{
- .x = destination->width + destination->x,
- .y = destination->height + destination->y,
+ .x = destination.width + destination.x,
+ .y = destination.height + destination.y,
//.z = 0.0f,
- .color = color_applied,
+ .color = color,
.texture_id = texture_uniform_slot,
.texture_x = source_applied.width + source_applied.x,
.texture_y = source_applied.height + source_applied.y,
@@ -511,10 +499,10 @@ rodeo_gfx_texture_2d_draw(
irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] =
(rodeo_gfx_vertex_t)
{
- .x = destination->width + destination->x,
- .y = destination->y,
+ .x = destination.width + destination.x,
+ .y = destination.y,
//.z = 0.0f,
- .color = color_applied,
+ .color = color,
.texture_id = texture_uniform_slot,
.texture_x = source_applied.width + source_applied.x,
.texture_y = source_applied.y,
@@ -523,10 +511,10 @@ rodeo_gfx_texture_2d_draw(
irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] =
(rodeo_gfx_vertex_t)
{
- .x = destination->x,
- .y = destination->y,
+ .x = destination.x,
+ .y = destination.y,
//.z = 0.0f,
- .color = color_applied,
+ .color = color,
.texture_id = texture_uniform_slot,
.texture_x = source_applied.x,
.texture_y = source_applied.y,
@@ -535,10 +523,10 @@ rodeo_gfx_texture_2d_draw(
irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] =
(rodeo_gfx_vertex_t)
{
- .x = destination->x,
- .y = destination->height + destination->y,
+ .x = destination.x,
+ .y = destination.height + destination.y,
//.z = 0.0f,
- .color = color_applied,
+ .color = color,
.texture_id = texture_uniform_slot,
.texture_x = source_applied.x,
.texture_y = source_applied.height + source_applied.y,
diff --git a/src/input/irodeo_input_t.h b/src/input/irodeo_input_t.h
index 77e150e..702e381 100644
--- a/src/input/irodeo_input_t.h
+++ b/src/input/irodeo_input_t.h
@@ -4,9 +4,9 @@
// public
#include "rodeo/input_t.h"
-typedef rodeo_input_scene_t *rodeo_input_scene_p;
+//typedef rodeo_input_scene_t *rodeo_input_scene_p;
#define i_tag input_scene
-#define i_key rodeo_input_scene_p
+#define i_key rodeo_input_scene_data_t*
#include <stc/cset.h>
typedef
diff --git a/src/input/rodeo_input.c b/src/input/rodeo_input.c
index 27b9776..63dc0b1 100644
--- a/src/input/rodeo_input.c
+++ b/src/input/rodeo_input.c
@@ -54,10 +54,10 @@ rodeo_input_poll(void)
{
c_foreach(i, cset_input_scene, istate.active_scenes)
{
- rodeo_input_scene_t *scene = *i.ref;
- c_foreach(j, cset_input_commands, scene->commands)
+ rodeo_input_scene_data_t *scene_data = *i.ref;
+ c_foreach(j, cset_input_commands, scene_data->commands)
{
- rodeo_input_command_t *command = *j.ref;
+ rodeo_input_command_data_t *command = *j.ref;
const cset_input_binary_scancodes_value *value = cset_input_binary_scancodes_get(
&command->binary.scancodes,
(rodeo_input_binary_scancode_t)event.key.keysym.scancode
@@ -91,10 +91,10 @@ rodeo_input_poll(void)
{
c_foreach(i, cset_input_scene, istate.active_scenes)
{
- rodeo_input_scene_t *scene = *i.ref;
- c_foreach(j, cset_input_commands, scene->commands)
+ rodeo_input_scene_data_t *scene_data = *i.ref;
+ c_foreach(j, cset_input_commands, scene_data->commands)
{
- rodeo_input_command_t *command = *j.ref;
+ rodeo_input_command_data_t *command = *j.ref;
const cset_input_binary_mouseButtons_value *value = cset_input_binary_mouseButtons_get(
&command->binary.mouse_buttons,
(rodeo_input_binary_mouseButton_t)event.button.button
@@ -128,10 +128,10 @@ rodeo_input_poll(void)
{
c_foreach(i, cset_input_scene, istate.active_scenes)
{
- rodeo_input_scene_t *scene = *i.ref;
- c_foreach(j, cset_input_commands, scene->commands)
+ rodeo_input_scene_data_t *scene_data = *i.ref;
+ c_foreach(j, cset_input_commands, scene_data->commands)
{
- rodeo_input_command_t *command = *j.ref;
+ rodeo_input_command_data_t *command = *j.ref;
const cset_input_positional_mouse_value *x_value = cset_input_positional_mouse_get(
&command->positional.mouse_axes,
rodeo_input_positional_mouse_X
@@ -222,11 +222,11 @@ rodeo_input_poll(void)
{
c_foreach(i, cset_input_scene, istate.active_scenes)
{
- rodeo_input_scene_t *scene = *i.ref;
- c_foreach(j, cset_input_commands, scene->commands)
+ rodeo_input_scene_data_t *scene_data = *i.ref;
+ c_foreach(j, cset_input_commands, scene_data->commands)
{
- rodeo_input_command_t *command = *j.ref;
- const cset_input_binary_controllerButton_value *value = cset_input_binary_controllerButton_get(
+ rodeo_input_command_data_t *command = *j.ref;
+ const cset_input_binary_controllerButtons_value *value = cset_input_binary_controllerButtons_get(
&command->binary.controller_buttons,
(rodeo_input_binary_controllerButton_t)event.cbutton.button
);
@@ -258,11 +258,11 @@ rodeo_input_poll(void)
{
c_foreach(i, cset_input_scene, istate.active_scenes)
{
- rodeo_input_scene_t *scene = *i.ref;
- c_foreach(j, cset_input_commands, scene->commands)
+ rodeo_input_scene_data_t *scene_data = *i.ref;
+ c_foreach(j, cset_input_commands, scene_data->commands)
{
- rodeo_input_command_t *command = *j.ref;
- if(cset_input_boundedRange_controllerAxis_contains(&command->bounded_range.controller_axes, event.caxis.axis))
+ rodeo_input_command_data_t *command = *j.ref;
+ if(cset_input_boundedRange_controllerAxes_contains(&command->bounded_range.controller_axes, event.caxis.axis))
{
rodeo_input_any_state_t input_state = {
.data.bounded_range_state =
@@ -308,14 +308,14 @@ rodeo_input_poll(void)
void
rodeo_input_command_register_callback(
- rodeo_input_command_t *command,
+ rodeo_input_command_t command,
rodeo_input_callback_function func
)
{
- const cset_input_callback_functions_value *callback = cset_input_callback_functions_get(&(command->callbacks), func);
+ const cset_input_callback_functions_value *callback = cset_input_callback_functions_get(&(command.data->callbacks), func);
if(callback == NULL)
{
- cset_input_callback_functions_insert(&(command->callbacks), func);
+ cset_input_callback_functions_insert(&(command.data->callbacks), func);
return;
}
else
@@ -330,15 +330,15 @@ rodeo_input_command_register_callback(
void
rodeo_input_command_unregister_callback(
- rodeo_input_command_t *command,
+ rodeo_input_command_t command,
rodeo_input_callback_function func
)
{
cset_input_callback_functions_value *callback =
- cset_input_callback_functions_get_mut(&(command->callbacks), func);
+ cset_input_callback_functions_get_mut(&(command.data->callbacks), func);
if(callback != NULL)
{
- cset_input_callback_functions_erase_entry(&(command->callbacks), callback);
+ cset_input_callback_functions_erase_entry(&(command.data->callbacks), callback);
return;
}
else
@@ -351,49 +351,54 @@ rodeo_input_command_unregister_callback(
}
}
-rodeo_input_scene_t*
+rodeo_input_scene_t
rodeo_input_scene_create(void)
{
- rodeo_input_scene_t *result = malloc(sizeof(rodeo_input_scene_t));
- *result = (rodeo_input_scene_t){0};
+ rodeo_input_scene_t result = {0};
+ result.data = calloc(1, sizeof(cset_input_commands));
+ if(result.data == NULL)
+ {
+ rodeo_log(
+ rodeo_logLevel_error,
+ "Failed to allocate a scene"
+ );
+ }
return result;
}
void
-rodeo_input_scene_destroy(rodeo_input_scene_t *scene)
+rodeo_input_scene_destroy(rodeo_input_scene_t scene)
{
rodeo_input_scene_deactivate(scene);
- cset_input_commands_drop(&scene->commands);
- free(scene);
+ cset_input_commands_drop(&scene.data->commands);
+ free(scene.data);
}
-rodeo_input_command_t*
+rodeo_input_command_t
rodeo_input_command_create(uint32_t input_types)
{
- rodeo_input_command_t *result = malloc(sizeof(rodeo_input_command_t));
- *result = (rodeo_input_command_t)
- {
- .valid_types = input_types
- };
+ rodeo_input_command_t result = {0};
+ result.data = calloc(1, sizeof(rodeo_input_command_data_t));
+ result.data->valid_types = input_types;
return result;
}
void
-rodeo_input_command_destroy(rodeo_input_command_t *command)
+rodeo_input_command_destroy(rodeo_input_command_t command)
{
- cset_input_binary_scancodes_drop(&command->binary.scancodes);
- cset_input_binary_mouseButtons_drop(&command->binary.mouse_buttons);
- cset_input_callback_functions_drop(&command->callbacks);
- free(command);
+ cset_input_binary_scancodes_drop(&command.data->binary.scancodes);
+ cset_input_binary_mouseButtons_drop(&command.data->binary.mouse_buttons);
+ cset_input_callback_functions_drop(&command.data->callbacks);
+ free(command.data);
}
bool
rodeo_input_command_register_binary_scancode(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_scancode_t scancode
)
{
- if((rodeo_input_type_Binary & input_command->valid_types) == 0)
+ if((rodeo_input_type_Binary & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -404,7 +409,7 @@ rodeo_input_command_register_binary_scancode(
else
{
cset_input_binary_scancodes_insert(
- &input_command->binary.scancodes,
+ &input_command.data->binary.scancodes,
scancode
);
return true;
@@ -413,11 +418,11 @@ rodeo_input_command_register_binary_scancode(
bool
rodeo_input_command_register_binary_controllerButton(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_controllerButton_t button
)
{
- if((rodeo_input_type_Binary & input_command->valid_types) == 0)
+ if((rodeo_input_type_Binary & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -427,8 +432,8 @@ rodeo_input_command_register_binary_controllerButton(
}
else
{
- cset_input_binary_controllerButton_insert(
- &input_command->binary.controller_buttons,
+ cset_input_binary_controllerButtons_insert(
+ &input_command.data->binary.controller_buttons,
button
);
return true;
@@ -437,11 +442,11 @@ rodeo_input_command_register_binary_controllerButton(
bool
rodeo_input_command_register_binary_mouseButton(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_binary_mouseButton_t mouse_button
)
{
- if((rodeo_input_type_Binary & input_command->valid_types) == 0)
+ if((rodeo_input_type_Binary & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -452,7 +457,7 @@ rodeo_input_command_register_binary_mouseButton(
else
{
cset_input_binary_mouseButtons_insert(
- &input_command->binary.mouse_buttons,
+ &input_command.data->binary.mouse_buttons,
mouse_button
);
return true;
@@ -461,11 +466,11 @@ rodeo_input_command_register_binary_mouseButton(
bool
rodeo_input_command_register_positional_mouse(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_positional_mouse_t mouse_axis
)
{
- if((rodeo_input_type_Positional & input_command->valid_types) == 0)
+ if((rodeo_input_type_Positional & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -476,7 +481,7 @@ rodeo_input_command_register_positional_mouse(
else
{
cset_input_positional_mouse_insert(
- &input_command->positional.mouse_axes,
+ &input_command.data->positional.mouse_axes,
mouse_axis
);
return true;
@@ -485,11 +490,11 @@ rodeo_input_command_register_positional_mouse(
bool
rodeo_input_command_register_boundedRange_controllerAxis(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_boundedRange_controllerAxis_t controller_axis
)
{
- if((rodeo_input_type_BoundedRange & input_command->valid_types) == 0)
+ if((rodeo_input_type_BoundedRange & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -499,8 +504,8 @@ rodeo_input_command_register_boundedRange_controllerAxis(
}
else
{
- cset_input_boundedRange_controllerAxis_insert(
- &input_command->bounded_range.controller_axes,
+ cset_input_boundedRange_controllerAxes_insert(
+ &input_command.data->bounded_range.controller_axes,
controller_axis
);
return true;
@@ -509,11 +514,11 @@ rodeo_input_command_register_boundedRange_controllerAxis(
bool
rodeo_input_command_register_unboundedRange_mouse(
- rodeo_input_command_t *input_command,
+ rodeo_input_command_t input_command,
rodeo_input_unboundedRange_mouse_t mouse_axis
)
{
- if((rodeo_input_type_UnboundedRange & input_command->valid_types) == 0)
+ if((rodeo_input_type_UnboundedRange & input_command.data->valid_types) == 0)
{
rodeo_log(
rodeo_logLevel_error,
@@ -524,7 +529,7 @@ rodeo_input_command_register_unboundedRange_mouse(
else
{
cset_input_unboundedRange_mouse_insert(
- &input_command->unbounded_range.mouse_axes,
+ &input_command.data->unbounded_range.mouse_axes,
mouse_axis
);
return true;
@@ -533,38 +538,38 @@ rodeo_input_command_register_unboundedRange_mouse(
void
rodeo_input_scene_register_command(
- rodeo_input_scene_t *scene,
- rodeo_input_command_t *command
+ rodeo_input_scene_t scene,
+ rodeo_input_command_t command
)
{
cset_input_commands_insert(
- &scene->commands,
- command
+ &scene.data->commands,
+ command.data
);
}
void
rodeo_input_scene_unregister_command(
- rodeo_input_scene_t *scene,
- rodeo_input_command_t *command
+ rodeo_input_scene_t scene,
+ rodeo_input_command_t command
)
{
cset_input_commands_erase(
- &scene->commands,
- command
+ &scene.data->commands,
+ command.data
);
}
void
-rodeo_input_scene_activate(rodeo_input_scene_t *scene)
+rodeo_input_scene_activate(rodeo_input_scene_t scene)
{
- cset_input_scene_insert(&istate.active_scenes, scene);
+ cset_input_scene_insert(&istate.active_scenes, scene.data);
}
void
-rodeo_input_scene_deactivate(rodeo_input_scene_t *scene)
+rodeo_input_scene_deactivate(rodeo_input_scene_t scene)
{
- cset_input_scene_erase(&istate.active_scenes, scene);
+ cset_input_scene_erase(&istate.active_scenes, scene.data);
}
#define i_key int32_t