2021-11-30 21:29:18 -06:00
|
|
|
#ifndef RENDER_H
|
|
|
|
#define RENDER_H
|
|
|
|
|
2023-05-22 00:08:08 -05:00
|
|
|
#include "sokol/sokol_gfx.h"
|
2023-05-16 01:31:13 -05:00
|
|
|
|
2023-05-30 13:07:18 -05:00
|
|
|
#include "HandmadeMath.h"
|
|
|
|
|
2023-05-16 01:31:13 -05:00
|
|
|
struct uv_n {
|
|
|
|
unsigned short u;
|
|
|
|
unsigned short v;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct st_n {
|
|
|
|
struct uv_n s;
|
|
|
|
struct uv_n t;
|
|
|
|
};
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
struct rgba {
|
|
|
|
unsigned char r;
|
|
|
|
unsigned char g;
|
|
|
|
unsigned char b;
|
|
|
|
unsigned char a;
|
|
|
|
};
|
|
|
|
|
2023-05-30 13:07:18 -05:00
|
|
|
struct boundingbox {
|
|
|
|
float t;
|
|
|
|
float b;
|
|
|
|
float r;
|
|
|
|
float l;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct boundingbox cwh2bb(HMM_Vec2 c, HMM_Vec2 wh) {
|
|
|
|
struct boundingbox bb = {
|
|
|
|
.t = c.Y + wh.Y/2,
|
|
|
|
.b = c.Y - wh.Y/2,
|
|
|
|
.r = c.X + wh.X/2,
|
|
|
|
.l = c.X - wh.X/2
|
|
|
|
};
|
|
|
|
|
|
|
|
return bb;
|
|
|
|
}
|
|
|
|
|
2023-05-24 20:45:50 -05:00
|
|
|
static float *rgba2floats(float *r, struct rgba c)
|
|
|
|
{
|
|
|
|
r[0] = c.r / 255.0;
|
|
|
|
r[1] = c.g / 255.0;
|
|
|
|
r[2] = c.b / 255.0;
|
|
|
|
r[3] = c.a / 255.0;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2023-05-22 00:08:08 -05:00
|
|
|
static sg_blend_state blend_trans = {
|
|
|
|
.enabled = true,
|
|
|
|
.src_factor_rgb = SG_BLENDFACTOR_SRC_ALPHA,
|
|
|
|
.dst_factor_rgb = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA,
|
|
|
|
.src_factor_alpha = SG_BLENDFACTOR_SRC_ALPHA,
|
|
|
|
.src_factor_alpha = SG_BLENDFACTOR_ONE_MINUS_SRC_ALPHA
|
|
|
|
};
|
|
|
|
|
2022-02-06 10:14:57 -06:00
|
|
|
#endif
|