FastUIDraw
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
fastuidraw::PainterSurface::Viewport Class Reference

#include <painter_surface.hpp>

Public Member Functions

 Viewport (int x, int y, int w, int h)
 
void compute_clip_equations (ivec2 surface_dims, vecN< vec3, 4 > *out_clip_equations) const
 
void compute_normalized_clip_rect (ivec2 surface_dims, Rect *out_rect) const
 
vec2 compute_normalized_device_coords (vec2 pixel) const
 
vec2 compute_normalized_device_coords_from_viewport_coords (vec2 viewport_coords) const
 
vec2 compute_normalized_device_coords_from_viewport_coords (ivec2 viewport_coords) const
 
vec2 compute_pixel_coordinates (vec2 ndc) const
 
vec2 compute_viewport_coordinates (vec2 ndc) const
 
ivec2 compute_visible_dimensions (ivec2 surface_dims) const
 
ivec2 visible_dimensions (void) const
 

Static Public Member Functions

static vec2 compute_viewport_coordinates (vec2 ndc, vec2 dims)
 
static vec2 compute_viewport_coordinates (vec2 ndc, ivec2 dims)
 

Public Attributes

ivec2 m_dimensions
 
ivec2 m_origin
 

Detailed Description

A Viewport specifies the sub-region within a Surface to which one renders.

Definition at line 70 of file painter_surface.hpp.

Constructor & Destructor Documentation

◆ Viewport()

fastuidraw::PainterSurface::Viewport::Viewport ( int  x,
int  y,
int  w,
int  h 
)
inline

Ctor.

Parameters
xvalue with which to initialize x-coordinate of m_origin
yvalue with which to initialize y-coordinate of m_origin
wvalue with which to initialize x-coordinate of m_dimensions
hvalue with which to initialize y-coordinate of m_dimensions

Definition at line 85 of file painter_surface.hpp.

Member Function Documentation

◆ compute_clip_equations()

void fastuidraw::PainterSurface::Viewport::compute_clip_equations ( ivec2  surface_dims,
vecN< vec3, 4 > *  out_clip_equations 
) const

Computes the clip-equations (in normalized device coordinates) of this Viewport against a surface with the given dimensions.

Parameters
surface_dimsdimension of surface
[out]out_clip_equationslocation to which to write the clip equations

◆ compute_normalized_clip_rect()

void fastuidraw::PainterSurface::Viewport::compute_normalized_clip_rect ( ivec2  surface_dims,
Rect out_rect 
) const

Computes the rectangle in normalized device coordinates of the intersection of a backing surface with the given dimensions against this Viewport.

Parameters
surface_dimsdimension of surface
[out]out_rectlocation to which to write the clipping rectangle in normalized device coordinates

◆ compute_normalized_device_coords()

vec2 fastuidraw::PainterSurface::Viewport::compute_normalized_device_coords ( vec2  pixel) const
inline

Compute normalized device coordinates from pixel coordinates.

Parameters
pixelpixel coordinates where (0, 0) corresponds to bottom left of the surface

Definition at line 153 of file painter_surface.hpp.

◆ compute_normalized_device_coords_from_viewport_coords() [1/2]

vec2 fastuidraw::PainterSurface::Viewport::compute_normalized_device_coords_from_viewport_coords ( vec2  viewport_coords) const
inline

Compute normalized device coordinates from viewport coordinates.

Parameters
viewport_coordsviewport coordinates

Definition at line 168 of file painter_surface.hpp.

◆ compute_normalized_device_coords_from_viewport_coords() [2/2]

vec2 fastuidraw::PainterSurface::Viewport::compute_normalized_device_coords_from_viewport_coords ( ivec2  viewport_coords) const
inline

Compute normalized device coordinates from viewport coordinates.

Parameters
viewport_coordsviewport coordinates

Definition at line 182 of file painter_surface.hpp.

◆ compute_pixel_coordinates()

vec2 fastuidraw::PainterSurface::Viewport::compute_pixel_coordinates ( vec2  ndc) const
inline

Compute pixel coordinates from normalized device coords using this Viewport values. The pixel coordinates are so that (0, 0) is the bottom left.

Parameters
ndcnormalized device coordinates

Definition at line 97 of file painter_surface.hpp.

◆ compute_viewport_coordinates() [1/3]

static vec2 fastuidraw::PainterSurface::Viewport::compute_viewport_coordinates ( vec2  ndc,
vec2  dims 
)
inlinestatic

Compute viewport coordiantes from normalized device coordinates

Parameters
ndcnormalized device coordinates
dimssize of viewport (i.e. the value of m_dimensions)

Definition at line 113 of file painter_surface.hpp.

◆ compute_viewport_coordinates() [2/3]

static vec2 fastuidraw::PainterSurface::Viewport::compute_viewport_coordinates ( vec2  ndc,
ivec2  dims 
)
inlinestatic

Compute viewport coordiantes from normalized device coordinates

Parameters
ndcnormalized device coordinates
dimssize of viewport (i.e. the value of m_dimensions)

Definition at line 128 of file painter_surface.hpp.

◆ compute_viewport_coordinates() [3/3]

vec2 fastuidraw::PainterSurface::Viewport::compute_viewport_coordinates ( vec2  ndc) const
inline

Compute viewport coordinates from normalized device coords using this Viewport values. The viewport coordinates are so that (0, 0) corresponds to pixel coordinates of value m_origin.

Parameters
ndcnormalized device coordinates

Definition at line 141 of file painter_surface.hpp.

◆ compute_visible_dimensions()

ivec2 fastuidraw::PainterSurface::Viewport::compute_visible_dimensions ( ivec2  surface_dims) const
inline

Computes the dimensions of the intersection of this viewport against a surface with the given resolution.

Parameters
surface_dimsdimension of surface

Definition at line 236 of file painter_surface.hpp.

◆ visible_dimensions()

ivec2 fastuidraw::PainterSurface::Viewport::visible_dimensions ( void  ) const
inline

Returne the size needed by a surface to contain the viewport, i.e. how many pixels the viewport covers.

Definition at line 217 of file painter_surface.hpp.

Member Data Documentation

◆ m_dimensions

ivec2 fastuidraw::PainterSurface::Viewport::m_dimensions

The dimensions of the viewport

Definition at line 253 of file painter_surface.hpp.

◆ m_origin

ivec2 fastuidraw::PainterSurface::Viewport::m_origin

The origin of the viewport

Definition at line 248 of file painter_surface.hpp.


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