nngn
anonymous_namespace{terminal.cpp}::Rasterizer Class Reference

Axis-aligned sprite rasterizer with texture sampling. More...

Public Member Functions

void update_projection (nngn::uvec2 term_size, nngn::uvec2 window_size, const nngn::Graphics::Camera &c)
 
void rasterize (std::size_t vbo_n, const nngn::Vertex *vbo, std::size_t ebo_n, const std::uint32_t *ebo, std::size_t n_textures, const Texture *textures, FrameBuffer *framebuffer) const
 

Private Member Functions

std::array< nngn::vec3, 4 > to_clip (nngn::Vertex v0, nngn::Vertex v1) const
 Transforms world-space vertices into clip space. More...
 
nngn::vec2 to_screen (nngn::vec3 v) const
 Transforms clip-space vertices into screen space. More...
 

Static Private Member Functions

static bool clip (nngn::vec3 bl, nngn::vec3 tr)
 Checks whether a sprite lies entirely outside of the clip volume. More...
 
static std::size_t clamp_floor (float max, float v)
 Clamps value between 0 and max, rounds toward -infinity. More...
 
static std::size_t clamp_ceil (float max, float v)
 Clamps value between 0 and max, rounds toward +infinity. More...
 
static float uv_coord (float p0, std::size_t p, float p1, float t0, float t1)
 Calculates texture coordinates for a given position in a sprite. More...
 

Private Attributes

nngn::vec3 size = {}
 
nngn::mat4 proj = {}
 

Detailed Description

Axis-aligned sprite rasterizer with texture sampling.

Member Function Documentation

◆ clamp_ceil()

std::size_t anonymous_namespace{terminal.cpp}::Rasterizer::clamp_ceil ( float  max,
float  v 
)
staticprivate

Clamps value between 0 and max, rounds toward +infinity.

Here is the caller graph for this function:

◆ clamp_floor()

std::size_t anonymous_namespace{terminal.cpp}::Rasterizer::clamp_floor ( float  max,
float  v 
)
staticprivate

Clamps value between 0 and max, rounds toward -infinity.

Here is the caller graph for this function:

◆ clip()

bool anonymous_namespace{terminal.cpp}::Rasterizer::clip ( nngn::vec3  bl,
nngn::vec3  tr 
)
staticprivate

Checks whether a sprite lies entirely outside of the clip volume.

Here is the caller graph for this function:

◆ rasterize()

void anonymous_namespace{terminal.cpp}::Rasterizer::rasterize ( std::size_t  vbo_n,
const nngn::Vertex vbo,
std::size_t  ebo_n,
const std::uint32_t *  ebo,
std::size_t  n_textures,
const Texture textures,
FrameBuffer framebuffer 
) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_clip()

std::array< nngn::vec3, 4 > anonymous_namespace{terminal.cpp}::Rasterizer::to_clip ( nngn::Vertex  v0,
nngn::Vertex  v1 
) const
private

Transforms world-space vertices into clip space.

Returns
{bl, tr, bt, tt}: bottom-left/top-right vertices / texture coordinates
Here is the caller graph for this function:

◆ to_screen()

nngn::vec2 anonymous_namespace{terminal.cpp}::Rasterizer::to_screen ( nngn::vec3  v) const
private

Transforms clip-space vertices into screen space.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_projection()

void anonymous_namespace{terminal.cpp}::Rasterizer::update_projection ( nngn::uvec2  term_size,
nngn::uvec2  window_size,
const nngn::Graphics::Camera c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ uv_coord()

float anonymous_namespace{terminal.cpp}::Rasterizer::uv_coord ( float  p0,
std::size_t  p,
float  p1,
float  t0,
float  t1 
)
staticprivate

Calculates texture coordinates for a given position in a sprite.

Here is the caller graph for this function:

Member Data Documentation

◆ proj

nngn::mat4 anonymous_namespace{terminal.cpp}::Rasterizer::proj = {}
private

◆ size

nngn::vec3 anonymous_namespace{terminal.cpp}::Rasterizer::size = {}
private

The documentation for this class was generated from the following file: