From ed08b673c50b076042d8f0c49501372168142764 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 16 Feb 2018 16:04:32 -0500 Subject: 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. --- src/renderer/renderer.h | 114 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 src/renderer/renderer.h (limited to 'src/renderer/renderer.h') 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 @@ +#ifndef RENDERER_H +#define RENDERER_H + +#include "gl.h" +#include "wrappers.h" +#include "mesh.h" +#include "shader.h" +#include + +class Texture; +struct Rectangle; + +class Renderer { +public: + + class Window { + public: + + Window(); + + Window(const Window& other) = delete; + Window& operator=(const Window& other) = delete; + + ~Window(); + + inline GLFWwindow* getHandle() + { + return window_; + } + + private: + + GLFWwindow* window_; + }; + + static inline bool isSingletonInitialized() + { + return singletonInitialized_; + } + + Renderer(); + + Renderer(const Renderer& other) = delete; + Renderer& operator=(const Renderer& other) = delete; + + ~Renderer(); + + inline Window& getWindow() + { + return window_; + } + + void fill( + Texture& tex, + Rectangle loc, + int r, + int g, + int b); + + void blit( + const Texture& src, + Texture& dst, + Rectangle srcrect, + Rectangle dstrect, + double alpha = 1.0); + + void renderScreen(const Texture& tex); + +private: + + friend void setFramebufferSize(GLFWwindow* w, int width, int height); + + void initializeFramebuffers(); + + void bloomPass1( + const GLTexture& src, + GLTexture& dst, + bool horizontal, + glm::vec2 srcRes, + glm::vec2 dstRes); + + static bool singletonInitialized_; + + Window window_; + GLVertexArray vao_; + + GLFramebuffer genericFb_; + GLFramebuffer bloomFb_; + GLRenderbuffer bloomDepth_; + + GLTexture renderPages_[2]; + GLTexture preBloomTex_; + GLTexture bloomPassTex1_; + GLTexture bloomPassTex2_; + + Mesh monitor_; + GLBuffer quadBuffer_; + + GLTexture artifactsTex_; + GLTexture scanlinesTex_; + + Shader ntscShader_; + Shader finalShader_; + Shader blitShader_; + Shader fillShader_; + Shader bloom1Shader_; + Shader bloom2Shader_; + + size_t curBuf_ = 0; + int width_; + int height_; +}; + +#endif -- cgit 1.4.1