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  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) override;
37 
38 private:
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 
53  std::unique_ptr<GLScaler> currScaler;
54 
55  gl::Texture colorTex[2];
56  gl::FrameBufferObject fbo[2];
57 
58  // Noise effect:
59  gl::Texture noiseTextureA;
60  gl::Texture noiseTextureB;
61  float noiseX, noiseY;
62 
63  struct TextureData {
64  gl::ColorTexture tex;
66  };
67  std::vector<std::pair<unsigned, TextureData>> textures;
68 
69  gl::ColorTexture superImposeTex;
70 
71  struct Region {
72  Region(unsigned srcStartY_, unsigned srcEndY_,
73  unsigned dstStartY_, unsigned dstEndY_,
74  unsigned lineWidth_)
75  : srcStartY(srcStartY_)
76  , srcEndY(srcEndY_)
77  , dstStartY(dstStartY_)
78  , dstEndY(dstEndY_)
79  , lineWidth(lineWidth_) {}
80  unsigned srcStartY;
81  unsigned srcEndY;
82  unsigned dstStartY;
83  unsigned dstEndY;
84  unsigned lineWidth;
85  };
86  std::vector<Region> regions;
87 
88  unsigned height;
89  unsigned frameCounter;
90 
93  RenderSettings::ScaleAlgorithm scaleAlgorithm;
94 
95  gl::ShaderProgram monitor3DProg;
96  gl::BufferObject arrayBuffer;
97  gl::BufferObject elementbuffer;
98 
99  bool storedFrame;
100 };
101 
102 } // namespace openmsx
103 
104 #endif // GLPOSTPROCESSOR_HH
Represents the output window/screen of openMSX.
Definition: Display.hh:31
std::unique_ptr< RawFrame > rotateFrames(std::unique_ptr< RawFrame > finishedFrame, EmuTime::param time) override
Sets up the "abcdFrame" variables for a new frame.
Most basic/generic texture: only contains a texture ID.
Definition: GLUtil.hh:35
void update(const Setting &setting) override
A frame buffer where pixels can be written to.
void paint(OutputSurface &output) override
Paint this layer.
Rasterizer using SDL.
GLPostProcessor(MSXMotherBoard &motherBoard, Display &display, OutputSurface &screen, const std::string &videoSource, unsigned maxWidth, unsigned height, bool canDoInterlace)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
OutputSurface & screen
The surface which is visible to the user.
Abstract base class for post processors.
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:393
ScaleAlgorithm
Scaler algorithm.