R2 Shaders
src
main
glsl
com
io7m
r2
shaders
sources
R2Viewport.h
Go to the documentation of this file.
1
#ifndef R2_VIEWPORT_H
2
#define R2_VIEWPORT_H
3
4
/// \file R2Viewport.h
5
/// \brief Viewport types and functions
6
7
/// The type of viewports.
8
9
struct
R2_viewport_t
{
10
/// 1.0 / width of viewport
11
float
inverse_width
;
12
/// 1.0 / height of viewport
13
float
inverse_height
;
14
};
15
16
///
17
/// Transform the fragment coordinate \a f_pos to UV
18
/// coordinates based on the given viewport \a v.
19
///
20
/// @param v The viewport
21
/// @param f_pos The current fragment coordinate (in window coordinates)
22
23
vec2
24
R2_viewportFragmentPositionToUV
(
25
const
R2_viewport_t
v,
26
const
vec2 f_pos)
27
{
28
return
vec2 (
29
f_pos.x * v.
inverse_width
,
30
f_pos.y * v.
inverse_height
31
);
32
}
33
34
#endif // R2_VIEWPORT_H
R2_viewport_t
The type of viewports.
Definition:
R2Viewport.h:9
R2_viewport_t::inverse_width
float inverse_width
1.0 / width of viewport
Definition:
R2Viewport.h:11
R2_viewportFragmentPositionToUV
vec2 R2_viewportFragmentPositionToUV(const R2_viewport_t v, const vec2 f_pos)
Definition:
R2Viewport.h:24
R2_viewport_t::inverse_height
float inverse_height
1.0 / height of viewport
Definition:
R2Viewport.h:13
Generated by
1.8.12