billboards!

This commit is contained in:
veclavtalica
2025-01-05 19:46:05 +03:00
parent 7c0bf39f12
commit 3bfa86066e
17 changed files with 626 additions and 413 deletions

View File

@ -54,6 +54,7 @@ TWN_API void draw_triangle(char const *texture,
// TODO: decide whether it's needed to begin with?
// intended usage for it is baked lighting, i would think.
// TODO: instead add optional color parameters to 'draw_triangle'
/* pushes a colored textured 3d triangle onto the render queue */
// void unfurl_colored_triangle(const char *path,
// Vec3 v0,
@ -66,7 +67,7 @@ TWN_API void draw_triangle(char const *texture,
// Color c1,
// Color c2);
TWN_API void draw_billboard(const char *path,
TWN_API void draw_billboard(const char *texture,
Vec3 position,
Vec2 size,
Color color, /* optional, default: all 255 */

View File

@ -9,6 +9,26 @@
#include <math.h>
static inline Vec2 vec2_add(Vec2 a, Vec2 b) {
return (Vec2) { a.x + b.x, a.y + b.y };
}
static inline Vec2 vec2_sub(Vec2 a, Vec2 b) {
return (Vec2) { a.x - b.x, a.y - b.y };
}
static inline Vec2 vec2_div(Vec2 a, Vec2 b) {
return (Vec2) { a.x / b.x, a.y / b.y };
}
static inline Vec2 vec2_mul(Vec2 a, Vec2 b) {
return (Vec2) { a.x * b.x, a.y * b.y };
}
static inline Vec2 vec2_scale(Vec2 a, float s) {
return (Vec2) { a.x * s, a.y * s };
}
static inline Vec3 vec3_add(Vec3 a, Vec3 b) {
return (Vec3) { a.x + b.x, a.y + b.y, a.z + b.z };
}
@ -17,12 +37,12 @@ static inline Vec3 vec3_sub(Vec3 a, Vec3 b) {
return (Vec3) { a.x - b.x, a.y - b.y, a.z - b.z };
}
static inline Vec2 vec2_div(Vec2 a, Vec2 b) {
return (Vec2) { a.x / b.x, a.y / b.y };
static inline Vec3 vec3_div(Vec3 a, Vec3 b) {
return (Vec3) { a.x / b.x, a.y / b.y, a.z / b.z };
}
static inline Vec2 vec2_scale(Vec2 a, float s) {
return (Vec2) { a.x * s, a.y * s };
static inline Vec3 vec3_mul(Vec3 a, Vec3 b) {
return (Vec3) { a.x * b.x, a.y * b.y, a.z * b.z };
}
static inline Vec3 vec3_scale(Vec3 a, float s) {
@ -83,15 +103,23 @@ static inline Vec3 vec3_rotate(Vec3 v, float angle, Vec3 axis) {
)(p_any_vec2))
#define m_vec_add(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_add, \
Vec3: vec3_add \
)(p_any_vec0, p_any_vec1))
#define m_vec_sub(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_sub, \
Vec3: vec3_sub \
)(p_any_vec0, p_any_vec1))
#define m_vec_div(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_div \
Vec2: vec2_div, \
Vec3: vec3_div \
)(p_any_vec0, p_any_vec1))
#define m_vec_mul(p_any_vec0, p_any_vec1) (_Generic((p_any_vec0), \
Vec2: vec2_mul, \
Vec3: vec3_mul \
)(p_any_vec0, p_any_vec1))
#define m_vec_scale(p_any_vec, p_any_scalar) (_Generic((p_any_vec), \