]> git.localhorst.tv Git - blobs.git/blob - src/graphics/Viewport.hpp
switch creatures with left click
[blobs.git] / src / graphics / Viewport.hpp
1 #ifndef BLOBS_GRAPHICS_VIEWPORT_HPP_
2 #define BLOBS_GRAPHICS_VIEWPORT_HPP_
3
4 #include "../math/geometry.hpp"
5
6
7 namespace blobs {
8 namespace graphics {
9
10 class Viewport {
11
12 public:
13         Viewport(int width, int height);
14         ~Viewport();
15
16         Viewport(const Viewport &) = delete;
17         Viewport &operator =(const Viewport &) = delete;
18
19         Viewport(Viewport &&) = delete;
20         Viewport &operator =(Viewport &&) = delete;
21
22 public:
23         int Width() const {
24                 return width;
25         }
26         int Height() const {
27                 return height;
28         }
29         void Resize(int w, int h);
30
31         math::Ray ShootPixel(int x, int y) const noexcept {
32                 return math::Ray({
33                         ((double(x) / double(width)) * 2.0) - 1.0,
34                         1.0 - ((double(y) / double(height)) * 2.0),
35                         -1.0 }, { 0.0, 0.0, 1.0 });
36         }
37
38         void Clear();
39         void ClearDepth();
40
41 private:
42         int width;
43         int height;
44
45 };
46
47 }
48 }
49
50 #endif