1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
#ifndef RENDERER_H
#define RENDERER_H
#include "gl.h"
#include "wrappers.h"
#include "mesh.h"
#include "shader.h"
#include <glm/glm.hpp>
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
|