openMSX
GLPostProcessor.hh
Go to the documentation of this file.
1 #ifndef GLPOSTPROCESSOR_HH
2 #define GLPOSTPROCESSOR_HH
3 
4 #include "PostProcessor.hh"
5 #include "RenderSettings.hh"
6 #include "GLUtil.hh"
7 #include <utility>
8 #include <vector>
9 #include <memory>
10 
11 namespace openmsx {
12 
13 class GLScaler;
14 class MSXMotherBoard;
15 class Display;
16 
19 class GLPostProcessor final : public PostProcessor
20 {
21 public:
23  MSXMotherBoard& motherBoard, Display& display,
24  OutputSurface& screen, const std::string& videoSource,
25  unsigned maxWidth, unsigned height, bool canDoInterlace);
26  ~GLPostProcessor() override;
27 
28  // Layer interface:
29  void paint(OutputSurface& output) override;
30 
31  [[nodiscard]] std::unique_ptr<RawFrame> rotateFrames(
32  std::unique_ptr<RawFrame> finishedFrame, EmuTime::param time) override;
33 
34 protected:
35  // Observer<Setting> interface:
36  void update(const Setting& setting) noexcept override;
37 
38 private:
39  void initBuffers();
40  void createRegions();
41  void uploadFrame();
42  void uploadBlock(unsigned srcStartY, unsigned srcEndY,
43  unsigned lineWidth);
44 
45  void preCalcNoise(float factor);
46  void drawNoise();
47  void drawGlow(int glow);
48 
49  void preCalcMonitor3D(float width);
50  void drawMonitor3D();
51 
52 private:
55  std::unique_ptr<GLScaler> currScaler;
56 
57  gl::Texture colorTex[2];
58  gl::FrameBufferObject fbo[2];
59 
60  // Noise effect:
61  gl::Texture noiseTextureA;
62  gl::Texture noiseTextureB;
63  float noiseX, noiseY;
64 
65  struct TextureData {
66  gl::ColorTexture tex;
68  };
69  std::vector<std::pair<unsigned, TextureData>> textures;
70 
71  gl::ColorTexture superImposeTex;
72 
73  struct Region {
74  Region(unsigned srcStartY_, unsigned srcEndY_,
75  unsigned dstStartY_, unsigned dstEndY_,
76  unsigned lineWidth_)
77  : srcStartY(srcStartY_)
78  , srcEndY(srcEndY_)
79  , dstStartY(dstStartY_)
80  , dstEndY(dstEndY_)
81  , lineWidth(lineWidth_) {}
82  unsigned srcStartY;
83  unsigned srcEndY;
84  unsigned dstStartY;
85  unsigned dstEndY;
86  unsigned lineWidth;
87  };
88  std::vector<Region> regions;
89 
90  unsigned height;
91  unsigned frameCounter;
92 
95  RenderSettings::ScaleAlgorithm scaleAlgorithm;
96 
97  gl::ShaderProgram monitor3DProg;
98  gl::BufferObject arrayBuffer;
99  gl::BufferObject elementbuffer;
100  gl::BufferObject vbo;
101  gl::BufferObject stretchVBO;
102 
103  bool storedFrame;
104 };
105 
106 } // namespace openmsx
107 
108 #endif // GLPOSTPROCESSOR_HH
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:389
Most basic/generic texture: only contains a texture ID.
Definition: GLUtil.hh:42
Represents the output window/screen of openMSX.
Definition: Display.hh:33
Rasterizer using SDL.
std::unique_ptr< RawFrame > rotateFrames(std::unique_ptr< RawFrame > finishedFrame, EmuTime::param time) override
Sets up the "abcdFrame" variables for a new frame.
GLPostProcessor(MSXMotherBoard &motherBoard, Display &display, OutputSurface &screen, const std::string &videoSource, unsigned maxWidth, unsigned height, bool canDoInterlace)
void paint(OutputSurface &output) override
Paint this layer.
void update(const Setting &setting) noexcept override
A frame buffer where pixels can be written to.
Abstract base class for post processors.
OutputSurface & screen
The surface which is visible to the user.
ScaleAlgorithm
Scaler algorithm.
This file implemented 3 utility functions:
Definition: Autofire.cc:5