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 <array>
8#include <memory>
9#include <vector>
10
11namespace openmsx {
12
13class GLScaler;
14class MSXMotherBoard;
15class Display;
16
19class GLPostProcessor final : public PostProcessor
20{
21public:
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
34protected:
35 // Observer<Setting> interface:
36 void update(const Setting& setting) noexcept override;
37
38private:
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
52private:
55 std::unique_ptr<GLScaler> currScaler;
56
57 std::array<gl::Texture, 2> colorTex;
58 std::array<gl::FrameBufferObject, 2> fbo;
59
60 // Noise effect:
61 gl::Texture noiseTextureA{true, true}; // interpolate + wrap
62 gl::Texture noiseTextureB{true, true};
63 float noiseX = 0.0f, noiseY = 0.0f;
64
65 struct TextureData {
68 [[nodiscard]] unsigned width() const { return tex.getWidth(); }
69 };
70 std::vector<TextureData> textures;
71
72 gl::ColorTexture superImposeTex;
73
74 struct Region {
75 Region(unsigned srcStartY_, unsigned srcEndY_,
76 unsigned dstStartY_, unsigned dstEndY_,
77 unsigned lineWidth_)
78 : srcStartY(srcStartY_)
79 , srcEndY(srcEndY_)
80 , dstStartY(dstStartY_)
81 , dstEndY(dstEndY_)
82 , lineWidth(lineWidth_) {}
83 unsigned srcStartY;
84 unsigned srcEndY;
85 unsigned dstStartY;
86 unsigned dstEndY;
87 unsigned lineWidth;
88 };
89 std::vector<Region> regions;
90
91 unsigned height;
92 unsigned frameCounter = 0;
93
97
98 gl::ShaderProgram monitor3DProg;
99 gl::BufferObject arrayBuffer;
100 gl::BufferObject elementBuffer;
102 gl::BufferObject stretchVBO;
103
104 bool storedFrame = false;
105};
106
107} // namespace openmsx
108
109#endif // GLPOSTPROCESSOR_HH
BaseSetting * setting
Definition: Interpreter.cc:28
GLsizei getWidth() const
Definition: GLUtil.hh:110
Wrapper around an OpenGL program: a collection of vertex and fragment shaders.
Definition: GLUtil.hh:387
Most basic/generic texture: only contains a texture ID.
Definition: GLUtil.hh:40
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