diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-16 16:04:32 -0500 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-02-16 16:04:32 -0500 |
| commit | ed08b673c50b076042d8f0c49501372168142764 (patch) | |
| tree | 18ecda99942ef11ce4023c3ad4437976f96b75da /src/renderer/renderer.h | |
| parent | 224645d1071c14b4829dbb3ae35870868fcff85a (diff) | |
| download | therapy-ed08b673c50b076042d8f0c49501372168142764.tar.gz therapy-ed08b673c50b076042d8f0c49501372168142764.tar.bz2 therapy-ed08b673c50b076042d8f0c49501372168142764.zip | |
Refactored renderer
Renderer is basically now more C++'y, as it makes more use of classes (a lot of GL types have been wrapped), and the renderer itself is now a class. The monitor mesh is also now indexed. Tweaked the NTSC artifacting after inadvertently fixing a bug with the way the image was loaded.
Diffstat (limited to 'src/renderer/renderer.h')
| -rw-r--r-- | src/renderer/renderer.h | 114 |
1 files changed, 114 insertions, 0 deletions
| diff --git a/src/renderer/renderer.h b/src/renderer/renderer.h new file mode 100644 index 0000000..0b10af5 --- /dev/null +++ b/src/renderer/renderer.h | |||
| @@ -0,0 +1,114 @@ | |||
| 1 | #ifndef RENDERER_H | ||
| 2 | #define RENDERER_H | ||
| 3 | |||
| 4 | #include "gl.h" | ||
| 5 | #include "wrappers.h" | ||
| 6 | #include "mesh.h" | ||
| 7 | #include "shader.h" | ||
| 8 | #include <glm/glm.hpp> | ||
| 9 | |||
| 10 | class Texture; | ||
| 11 | struct Rectangle; | ||
| 12 | |||
| 13 | class Renderer { | ||
| 14 | public: | ||
| 15 | |||
| 16 | class Window { | ||
| 17 | public: | ||
| 18 | |||
| 19 | Window(); | ||
| 20 | |||
| 21 | Window(const Window& other) = delete; | ||
| 22 | Window& operator=(const Window& other) = delete; | ||
| 23 | |||
| 24 | ~Window(); | ||
| 25 | |||
| 26 | inline GLFWwindow* getHandle() | ||
| 27 | { | ||
| 28 | return window_; | ||
| 29 | } | ||
| 30 | |||
| 31 | private: | ||
| 32 | |||
| 33 | GLFWwindow* window_; | ||
| 34 | }; | ||
| 35 | |||
| 36 | static inline bool isSingletonInitialized() | ||
| 37 | { | ||
| 38 | return singletonInitialized_; | ||
| 39 | } | ||
| 40 | |||
| 41 | Renderer(); | ||
| 42 | |||
| 43 | Renderer(const Renderer& other) = delete; | ||
| 44 | Renderer& operator=(const Renderer& other) = delete; | ||
| 45 | |||
| 46 | ~Renderer(); | ||
| 47 | |||
| 48 | inline Window& getWindow() | ||
| 49 | { | ||
| 50 | return window_; | ||
| 51 | } | ||
| 52 | |||
| 53 | void fill( | ||
| 54 | Texture& tex, | ||
| 55 | Rectangle loc, | ||
| 56 | int r, | ||
| 57 | int g, | ||
| 58 | int b); | ||
| 59 | |||
| 60 | void blit( | ||
| 61 | const Texture& src, | ||
| 62 | Texture& dst, | ||
| 63 | Rectangle srcrect, | ||
| 64 | Rectangle dstrect, | ||
| 65 | double alpha = 1.0); | ||
| 66 | |||
| 67 | void renderScreen(const Texture& tex); | ||
| 68 | |||
| 69 | private: | ||
| 70 | |||
| 71 | friend void setFramebufferSize(GLFWwindow* w, int width, int height); | ||
| 72 | |||
| 73 | void initializeFramebuffers(); | ||
| 74 | |||
| 75 | void bloomPass1( | ||
| 76 | const GLTexture& src, | ||
| 77 | GLTexture& dst, | ||
| 78 | bool horizontal, | ||
| 79 | glm::vec2 srcRes, | ||
| 80 | glm::vec2 dstRes); | ||
| 81 | |||
| 82 | static bool singletonInitialized_; | ||
| 83 | |||
| 84 | Window window_; | ||
| 85 | GLVertexArray vao_; | ||
| 86 | |||
| 87 | GLFramebuffer genericFb_; | ||
| 88 | GLFramebuffer bloomFb_; | ||
| 89 | GLRenderbuffer bloomDepth_; | ||
| 90 | |||
| 91 | GLTexture renderPages_[2]; | ||
| 92 | GLTexture preBloomTex_; | ||
| 93 | GLTexture bloomPassTex1_; | ||
| 94 | GLTexture bloomPassTex2_; | ||
| 95 | |||
| 96 | Mesh monitor_; | ||
| 97 | GLBuffer quadBuffer_; | ||
| 98 | |||
| 99 | GLTexture artifactsTex_; | ||
| 100 | GLTexture scanlinesTex_; | ||
| 101 | |||
| 102 | Shader ntscShader_; | ||
| 103 | Shader finalShader_; | ||
| 104 | Shader blitShader_; | ||
| 105 | Shader fillShader_; | ||
| 106 | Shader bloom1Shader_; | ||
| 107 | Shader bloom2Shader_; | ||
| 108 | |||
| 109 | size_t curBuf_ = 0; | ||
| 110 | int width_; | ||
| 111 | int height_; | ||
| 112 | }; | ||
| 113 | |||
| 114 | #endif | ||
