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 <vector>
8 #include <memory>
9 
10 namespace openmsx {
11 
12 class GLScaler;
13 class MSXMotherBoard;
14 class Display;
15 
18 class GLPostProcessor final : public PostProcessor
19 {
20 public:
22  MSXMotherBoard& motherBoard, Display& display,
23  OutputSurface& screen, const std::string& videoSource,
24  unsigned maxWidth, unsigned height, bool canDoInterlace);
25  ~GLPostProcessor() override;
26 
27  // Layer interface:
28  void paint(OutputSurface& output) override;
29 
30  [[nodiscard]] std::unique_ptr<RawFrame> rotateFrames(
31  std::unique_ptr<RawFrame> finishedFrame, EmuTime::param time) override;
32 
33 protected:
34  // Observer<Setting> interface:
35  void update(const Setting& setting) noexcept override;
36 
37 private:
38  void initBuffers();
39  void createRegions();
40  void uploadFrame();
41  void uploadBlock(unsigned srcStartY, unsigned srcEndY,
42  unsigned lineWidth);
43 
44  void preCalcNoise(float factor);
45  void drawNoise();
46  void drawGlow(int glow);
47 
48  void preCalcMonitor3D(float width);
49  void drawMonitor3D();
50 
51 private:
54  std::unique_ptr<GLScaler> currScaler;
55 
56  gl::Texture colorTex[2];
57  gl::FrameBufferObject fbo[2];
58 
59  // Noise effect:
60  gl::Texture noiseTextureA;
61  gl::Texture noiseTextureB;
62  float noiseX, noiseY;
63 
64  struct TextureData {
65  gl::ColorTexture tex;
67  [[nodiscard]] unsigned width() const { return tex.getWidth(); }
68  };
69  std::vector<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
BaseSetting * setting
Definition: Interpreter.cc:27
GLsizei getWidth() const
Definition: GLUtil.hh:111
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:388
Most basic/generic texture: only contains a texture ID.
Definition: GLUtil.hh:41
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:9