blob: df6ea0f98e75bbb63445b22e4e2d226d46ddfe35 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
// -- internal --
// public
#include "rodeo.h"
// private
#include "rodeo_internal.h"
// -- system --
#include <stdint.h>
#include <math.h>
// -- external --
#include "SDL.h"
#include "stc/crandom.h"
#define CGLM_FORCE_DEPTH_ZERO_TO_ONE
#include "cglm/cglm.h"
// rounds to nearest rather then truncation
rodeo_color_RGBA8_t
rodeo_color_RGBAFloat_to_RGBA8(const rodeo_color_RGBAFloat_t color)
{
return (rodeo_color_RGBA8_t){
.colors.red = (uint8_t)((color.colors.red * (float)UINT8_MAX) + 0.5),
.colors.green = (uint8_t)((color.colors.green * (float)UINT8_MAX) + 0.5),
.colors.blue = (uint8_t)((color.colors.blue * (float)UINT8_MAX) + 0.5),
.colors.alpha = (uint8_t)((color.colors.alpha * (float)UINT8_MAX) + 0.5),
};
}
rodeo_color_RGBAFloat_t
rodeo_color_RGBA8_to_RGBAFloat(const rodeo_color_RGBA8_t color)
{
return (rodeo_color_RGBAFloat_t){
.colors.red = (float)color.colors.red / 255.0f,
.colors.green = (float)color.colors.green / 255.0f,
.colors.blue = (float)color.colors.blue / 255.0f,
.colors.alpha = (float)color.colors.alpha / 255.0f,
};
}
// need to test this, might be wrong
/*
rodeo_vector2_t
rodeo_angle_to_vector2(float angle)
{
rodeo_vector2_t result = { {1.0f, 0.0f} };
glm_vec2_rotate(
(float*)&(result.array),
angle * 2.0f * (float)GLM_PI,
(float*)&result.array
);
return result;
}
*/
|