1#ifndef NNGN_RENDER_RENDERERS_H
2#define NNGN_RENDER_RENDERERS_H
30 void set_pos(
vec3 p) { this->pos = p; this->flags |= Flag::UPDATED; }
35 std::array<vec2, 2>
uv = {{{0, 1}, {1, 0}}};
39 template<
typename T, std::
size_t N>
40 static std::span<float>
uv_span(std::array<T, N> *
a);
51 std::array<vec4, 6>
uv = {};
57template<
typename T, std::
size_t N>
59 constexpr auto n =
N * T::n_dim;
60 static_assert(
sizeof(*a) ==
n *
sizeof(
float));
61 return {&(*a)[0][0],
n};
68 const auto fs =
static_cast<vec2>(scale);
69 const auto fc0 =
static_cast<vec2>(uv0) / fs;
70 const auto fc1 =
static_cast<vec2>(uv1) / fs;
71 s[0] = fc0.
x,
s[1] = 1 - fc0.y;
72 s[2] = fc1.x,
s[3] = 1 - fc1.y;
precision highp float
Definition common.h:15
assert
Definition debug.lua:3
local n
Definition dump_lights.lua:5
local N
Definition gamma.lua:5
pos
Definition lua_audio.cpp:17
std::uint32_t u32
Definition def.h:14
std::uint8_t u8
Definition def.h:12
load
Definition entity.lua:7
Definition renderers.h:44
float size
Definition renderers.h:46
vec3 color
Definition renderers.h:45
Wrapper for a small unsigned integral representing flags.
Definition flags.h:18
constexpr bool is_set(AT a) const
Definition flags.h:45
Definition renderers.h:15
float z_off
Definition renderers.h:27
Flags< Flag > flags
Definition renderers.h:28
void set_pos(vec3 p)
Definition renderers.h:30
Flag
Definition renderers.h:24
@ UPDATED
Definition renderers.h:24
bool updated() const
Definition renderers.h:29
Type
Definition renderers.h:16
@ CUBE
Definition renderers.h:20
@ SPRITE
Definition renderers.h:17
@ TRANSLUCENT
Definition renderers.h:19
@ VOXEL
Definition renderers.h:21
@ SCREEN_SPRITE
Definition renderers.h:18
@ N_TYPES
Definition renderers.h:22
Entity * entity
Definition renderers.h:25
Definition renderers.h:33
std::array< vec2, 2 > uv
Definition renderers.h:35
vec2 size
Definition renderers.h:34
u32 tex
Definition renderers.h:36
static std::span< float > uv_span(std::array< T, N > *a)
Definition renderers.h:58
static void uv_coords(uvec2 uv0, uvec2 uv1, uvec2 scale, std::span< float > s)
Definition renderers.h:64
Definition renderers.h:50
u32 tex
Definition renderers.h:53
std::array< vec4, 6 > uv
Definition renderers.h:51
vec3 size
Definition renderers.h:52
Non-owning reference to a table on the stack.
Definition table.h:166
Owning reference to a table on the stack, popped when destroyed.
Definition table.h:172
Operations on table values.
std::chrono::seconds s
Definition timing.cpp:6