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 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 
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  };
68  std::vector<std::pair<unsigned, TextureData>> textures;
69 
70  gl::ColorTexture superImposeTex;
71 
72  struct Region {
73  Region(unsigned srcStartY_, unsigned srcEndY_,
74  unsigned dstStartY_, unsigned dstEndY_,
75  unsigned lineWidth_)
76  : srcStartY(srcStartY_)
77  , srcEndY(srcEndY_)
78  , dstStartY(dstStartY_)
79  , dstEndY(dstEndY_)
80  , lineWidth(lineWidth_) {}
81  unsigned srcStartY;
82  unsigned srcEndY;
83  unsigned dstStartY;
84  unsigned dstEndY;
85  unsigned lineWidth;
86  };
87  std::vector<Region> regions;
88 
89  unsigned height;
90  unsigned frameCounter;
91 
94  RenderSettings::ScaleAlgorithm scaleAlgorithm;
95 
96  gl::VertexArray monitor3DVAO;
97  gl::ShaderProgram monitor3DProg;
98  gl::BufferObject arrayBuffer;
99  gl::BufferObject elementbuffer;
100  gl::VertexArray vao;
101  gl::VertexArray glowVAO;
102  gl::BufferObject vbo[2];
103  gl::BufferObject stretchVBO;
104  gl::VertexArray noiseVAO;
105  gl::BufferObject noiseVBO[2];
106 
107  bool storedFrame;
108 };
109 
110 } // namespace openmsx
111 
112 #endif // GLPOSTPROCESSOR_HH
gl::BufferObject
Definition: GLUtil.hh:431
openmsx::GLPostProcessor::paint
void paint(OutputSurface &output) override
Paint this layer.
Definition: GLPostProcessor.cc:148
gl::Texture
Most basic/generic texture: only contains a texture ID.
Definition: GLUtil.hh:35
gl::ColorTexture
Definition: GLUtil.hh:94
openmsx::GLPostProcessor::rotateFrames
std::unique_ptr< RawFrame > rotateFrames(std::unique_ptr< RawFrame > finishedFrame, EmuTime::param time) override
Sets up the "abcdFrame" variables for a new frame.
Definition: GLPostProcessor.cc:260
openmsx::GLPostProcessor::~GLPostProcessor
~GLPostProcessor() override
Definition: GLPostProcessor.cc:70
openmsx::Setting
Definition: Setting.hh:119
gl::FrameBufferObject
Definition: GLUtil.hh:114
openmsx::GLPostProcessor
Rasterizer using SDL.
Definition: GLPostProcessor.hh:19
openmsx::MSXMotherBoard
Definition: MSXMotherBoard.hh:59
PostProcessor.hh
openmsx::PostProcessor
Abstract base class for post processors.
Definition: PostProcessor.hh:29
gl::PixelBuffer< unsigned >
RenderSettings.hh
openmsx::GLPostProcessor::GLPostProcessor
GLPostProcessor(MSXMotherBoard &motherBoard, Display &display, OutputSurface &screen, const std::string &videoSource, unsigned maxWidth, unsigned height, bool canDoInterlace)
Definition: GLPostProcessor.cc:22
openmsx::Display
Represents the output window/screen of openMSX.
Definition: Display.hh:31
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:19
openmsx::PostProcessor::maxWidth
int maxWidth
Definition: PostProcessor.hh:142
gl::ShaderProgram
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:369
GLUtil.hh
openmsx::GLPostProcessor::update
void update(const Setting &setting) override
Definition: GLPostProcessor.cc:272
gl::VertexArray
Definition: GLUtil.hh:452
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::RenderSettings::ScaleAlgorithm
ScaleAlgorithm
Scaler algorithm.
Definition: RenderSettings.hh:36
openmsx::PostProcessor::screen
OutputSurface & screen
The surface which is visible to the user.
Definition: PostProcessor.hh:109