R2 Shaders
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
12  /// 1.0 / height of viewport
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
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
The type of viewports.
Definition: R2Viewport.h:9
float inverse_width
1.0 / width of viewport
Definition: R2Viewport.h:11
vec2 R2_viewportFragmentPositionToUV(const R2_viewport_t v, const vec2 f_pos)
Definition: R2Viewport.h:24
float inverse_height
1.0 / height of viewport
Definition: R2Viewport.h:13