OXYGENHUB
◆ main openmsx / src / video / scalers / GLTVScaler.cc
1.1 KiB · C++ · last changed chore(): initial commit 1 month ago source blame history raw
1
#include "GLTVScaler.hh"
2
3
#include "RenderSettings.hh"
4
5
namespace openmsx {
6
7
GLTVScaler::GLTVScaler(RenderSettings& renderSettings_)
8
	: GLScaler("tv")
9
	, renderSettings(renderSettings_)
10
{
11
	for (auto i : xrange(2)) {
12
		program[i].activate();
13
		unifMinScanline[i] =
14
			program[i].getUniformLocation("minScanline");
15
		unifSizeVariance[i] =
16
			program[i].getUniformLocation("sizeVariance");
17
	}
18
}
19
20
void GLTVScaler::scaleImage(
21
	gl::ColorTexture& src, gl::ColorTexture* superImpose,
22
	unsigned srcStartY, unsigned srcEndY, unsigned srcWidth,
23
	unsigned dstStartY, unsigned dstEndY, unsigned dstWidth,
24
	unsigned logSrcHeight)
25
{
26
	setup(superImpose != nullptr);
27
	int i = superImpose ? 1 : 0;
28
	// These are experimentally established functions that look good.
29
	// By design, both are 0 for scanline 0.
30
	float gap = renderSettings.getScanlineGap();
31
	glUniform1f(unifMinScanline [i], 0.1f * gap + 0.2f * gap * gap);
32
	glUniform1f(unifSizeVariance[i], 0.7f * gap - 0.3f * gap * gap);
33
	execute(src, superImpose,
34
	        srcStartY, srcEndY, srcWidth,
35
	        dstStartY, dstEndY, dstWidth,
36
	        logSrcHeight, true);
37
}
38
39
} // namespace openmsx