summaryrefslogtreecommitdiffhomepage
path: root/include/rodeo
diff options
context:
space:
mode:
Diffstat (limited to 'include/rodeo')
-rw-r--r--include/rodeo/gfx_t.h4
-rw-r--r--include/rodeo/math.h17
-rw-r--r--include/rodeo/math/mat4.h38
-rw-r--r--include/rodeo/math/mat4_t.h19
-rw-r--r--include/rodeo/math/rng.h48
-rw-r--r--include/rodeo/math/rng_t.h16
-rw-r--r--include/rodeo/math/vec2.h53
-rw-r--r--include/rodeo/math/vec2_t.h17
-rw-r--r--include/rodeo/math/vec3.h53
-rw-r--r--include/rodeo/math/vec3_t.h18
-rw-r--r--include/rodeo/math_t.h5
-rw-r--r--include/rodeo/window.h4
12 files changed, 288 insertions, 4 deletions
diff --git a/include/rodeo/gfx_t.h b/include/rodeo/gfx_t.h
index 9ed5f14..40ea58c 100644
--- a/include/rodeo/gfx_t.h
+++ b/include/rodeo/gfx_t.h
@@ -6,12 +6,12 @@
// -- system --
#include <inttypes.h>
-typedef struct irodeo_gfx_texture_internal irodeo_gfx_texture_internal_t;
+typedef struct irodeo_gfx_texture_2d irodeo_gfx_texture_2d_t;
typedef
struct
{
- irodeo_gfx_texture_internal_t *internal_texture;
+ irodeo_gfx_texture_2d_t *data;
uint32_t width;
uint32_t height;
}
diff --git a/include/rodeo/math.h b/include/rodeo/math.h
new file mode 100644
index 0000000..3896fef
--- /dev/null
+++ b/include/rodeo/math.h
@@ -0,0 +1,17 @@
+#pragma once
+
+// --- internal ---
+// public
+#include "rodeo/math_t.h"
+#include "rodeo/math/vec2.h"
+#include "rodeo/math/vec3.h"
+#include "rodeo/math/mat4.h"
+#include "rodeo/math/rng.h"
+
+#define mrodeo_math_pi 3.1415927410125732421875f
+
+float
+rodeo_math_radians_to_turns(float radians);
+
+float
+rodeo_math_turns_to_radians(float turns);
diff --git a/include/rodeo/math/mat4.h b/include/rodeo/math/mat4.h
new file mode 100644
index 0000000..5dbc872
--- /dev/null
+++ b/include/rodeo/math/mat4.h
@@ -0,0 +1,38 @@
+#pragma once
+
+// -- internal --
+// public
+#include "rodeo/math/mat4_t.h"
+#include "rodeo/math.h"
+
+rodeo_math_mat4_t
+rodeo_math_mat4_identity(void);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_zero(void);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_transpose(rodeo_math_mat4_t m);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_translate(rodeo_math_mat4_t m, rodeo_math_vec3_t v);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_scale(rodeo_math_mat4_t m, rodeo_math_vec3_t v);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_rotate(rodeo_math_mat4_t m, float turns, rodeo_math_vec3_t v);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_multiply(rodeo_math_mat4_t a, rodeo_math_mat4_t b);
+
+rodeo_math_mat4_t
+rodeo_math_mat4_orthographic(
+ float left,
+ float right,
+ float bottom,
+ float top,
+ float near,
+ float far
+);
+
diff --git a/include/rodeo/math/mat4_t.h b/include/rodeo/math/mat4_t.h
new file mode 100644
index 0000000..e00656c
--- /dev/null
+++ b/include/rodeo/math/mat4_t.h
@@ -0,0 +1,19 @@
+#pragma once
+
+typedef
+struct
+{
+ float m00, m01, m02, m03;
+ float m10, m11, m12, m13;
+ float m20, m21, m22, m23;
+ float m30, m31, m32, m33;
+}
+rodeo_math_mat4_val_t;
+
+typedef
+union
+{
+ rodeo_math_mat4_val_t val;
+ float raw[4][4];
+}
+rodeo_math_mat4_t;
diff --git a/include/rodeo/math/rng.h b/include/rodeo/math/rng.h
new file mode 100644
index 0000000..53f1f76
--- /dev/null
+++ b/include/rodeo/math/rng.h
@@ -0,0 +1,48 @@
+#pragma once
+
+// -- internal --
+#include "rodeo/math/rng_t.h"
+
+// -- system --
+#include <inttypes.h>
+
+void
+rodeo_math_rng_init(void);
+
+void
+rodeo_math_rng_deinit(void);
+
+rodeo_math_rng_generator_t
+rodeo_math_rng_generator_create(uint64_t seed);
+
+void
+rodeo_math_rng_generator_destroy(rodeo_math_rng_generator_t generator);
+
+double
+rodeo_math_rng_double_get(rodeo_math_rng_generator_t generator);
+
+#define irodeo_math_rng_double_get_default() rodeo_math_rng_double_get((rodeo_math_rng_generator_t){0})
+
+float
+rodeo_math_rng_float_get(rodeo_math_rng_generator_t generator);
+
+#define irodeo_math_rng_float_get_default() rodeo_math_rng_float_get((rodeo_math_rng_generator_t){0})
+
+uint64_t
+rodeo_math_rng_uint64_get(rodeo_math_rng_generator_t generator);
+
+#define irodeo_math_rng_uint64_get_default() rodeo_math_rng_uint64_get((rodeo_math_rng_generator_t){0})
+
+uint32_t
+rodeo_math_rng_uint32_get(rodeo_math_rng_generator_t generator);
+
+#define irodeo_math_rng_uint32_get_default() rodeo_math_rng_uint32_get((rodeo_math_rng_generator_t){0})
+
+#define \
+mrodeo_math_rng_do( \
+) \
+ mrodeo_defer_do( \
+ rodeo_math_rng_init(), \
+ rodeo_math_rng_deinit() \
+ )
+
diff --git a/include/rodeo/math/rng_t.h b/include/rodeo/math/rng_t.h
new file mode 100644
index 0000000..8c527ed
--- /dev/null
+++ b/include/rodeo/math/rng_t.h
@@ -0,0 +1,16 @@
+#pragma once
+
+// -- system --
+#include <inttypes.h>
+
+typedef struct irodeo_math_rng_generator irodeo_math_rng_generator_t;
+
+typedef
+struct
+{
+ // note: a seed value of '0' is reserved for when using the
+ // global seed is desired.
+ uint64_t seed;
+ irodeo_math_rng_generator_t *data;
+}
+rodeo_math_rng_generator_t;
diff --git a/include/rodeo/math/vec2.h b/include/rodeo/math/vec2.h
new file mode 100644
index 0000000..88d524f
--- /dev/null
+++ b/include/rodeo/math/vec2.h
@@ -0,0 +1,53 @@
+#pragma once
+
+// -- internal --
+// public
+#include "rodeo/math/vec2_t.h"
+
+rodeo_math_vec2_t
+rodeo_math_vec2_zero(void);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_one(void);
+
+float
+rodeo_math_vec2_dot(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+float
+rodeo_math_vec2_cross(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_add(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_subtract(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_multiply(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_scale(rodeo_math_vec2_t a, float b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_divide(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_negate(rodeo_math_vec2_t a);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_normalize(rodeo_math_vec2_t a);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_rotate(rodeo_math_vec2_t a, float turns);
+
+float
+rodeo_math_vec2_distance(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+float
+rodeo_math_vec2_distanceSq(rodeo_math_vec2_t a, rodeo_math_vec2_t b);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_clamp(rodeo_math_vec2_t a, float minimum, float maximum);
+
+rodeo_math_vec2_t
+rodeo_math_vec2_lerp(rodeo_math_vec2_t from, rodeo_math_vec2_t to, float t);
diff --git a/include/rodeo/math/vec2_t.h b/include/rodeo/math/vec2_t.h
new file mode 100644
index 0000000..22717c6
--- /dev/null
+++ b/include/rodeo/math/vec2_t.h
@@ -0,0 +1,17 @@
+#pragma once
+
+typedef
+struct
+{
+ float x;
+ float y;
+}
+rodeo_math_vec2_val_t;
+
+typedef
+union
+{
+ rodeo_math_vec2_val_t val;
+ float raw[2];
+}
+rodeo_math_vec2_t;
diff --git a/include/rodeo/math/vec3.h b/include/rodeo/math/vec3.h
new file mode 100644
index 0000000..1b9cd31
--- /dev/null
+++ b/include/rodeo/math/vec3.h
@@ -0,0 +1,53 @@
+#pragma once
+
+// -- internal --
+// public
+#include "rodeo/math/vec3_t.h"
+
+rodeo_math_vec3_t
+rodeo_math_vec3_zero(void);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_one(void);
+
+float
+rodeo_math_vec3_dot(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+float
+rodeo_math_vec3_cross(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_add(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_subtract(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_multiply(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_scale(rodeo_math_vec3_t a, float b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_divide(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_negate(rodeo_math_vec3_t a);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_normalize(rodeo_math_vec3_t a);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_rotate(rodeo_math_vec3_t a, float turns, rodeo_math_vec3_t axis);
+
+float
+rodeo_math_vec3_distance(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+float
+rodeo_math_vec3_distanceSq(rodeo_math_vec3_t a, rodeo_math_vec3_t b);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_clamp(rodeo_math_vec3_t a, float minimum, float maximum);
+
+rodeo_math_vec3_t
+rodeo_math_vec3_lerp(rodeo_math_vec3_t from, rodeo_math_vec3_t to, float t);
diff --git a/include/rodeo/math/vec3_t.h b/include/rodeo/math/vec3_t.h
new file mode 100644
index 0000000..a3b3a36
--- /dev/null
+++ b/include/rodeo/math/vec3_t.h
@@ -0,0 +1,18 @@
+#pragma once
+
+typedef
+struct
+{
+ float x;
+ float y;
+ float z;
+}
+rodeo_math_vec3_val_t;
+
+typedef
+union
+{
+ rodeo_math_vec3_val_t val;
+ float raw[3];
+}
+rodeo_math_vec3_t;
diff --git a/include/rodeo/math_t.h b/include/rodeo/math_t.h
new file mode 100644
index 0000000..9374c2a
--- /dev/null
+++ b/include/rodeo/math_t.h
@@ -0,0 +1,5 @@
+#pragma once
+
+// --- internal ---
+// public
+#include "rodeo/math/vec2_t.h"
diff --git a/include/rodeo/window.h b/include/rodeo/window.h
index 2dcfab2..df73b4f 100644
--- a/include/rodeo/window.h
+++ b/include/rodeo/window.h
@@ -13,8 +13,8 @@
void
rodeo_window_init(
- uint16_t screen_height,
- uint16_t screen_width,
+ uint32_t screen_height,
+ uint32_t screen_width,
cstr title
);