11 , renderSettings(renderSettings_)
16 unifTexStepX[i] =
program[i].getUniformLocation(
"texStepX");
17 unifCnst[i] =
program[i].getUniformLocation(
"cnst");
23 unsigned srcStartY,
unsigned srcEndY,
unsigned srcWidth,
24 unsigned dstStartY,
unsigned dstEndY,
unsigned dstWidth,
25 unsigned logSrcHeight)
27 int i = superImpose ? 1 : 0;
29 GLfloat blur = narrow<float>(renderSettings.
getBlurFactor()) * (1.0f / 256.0f);
30 GLfloat scanline = narrow<float>(renderSettings.
getScanlineFactor()) * (1.0f / 255.0f);
31 unsigned yScale = (dstEndY - dstStartY) / (srcEndY - srcStartY);
39 if ((blur != 0.0f) || (scanline != 1.0f) || superImpose) {
40 setup(superImpose !=
nullptr);
41 if ((blur != 0.0f) && (srcWidth != 1)) {
44 auto yScaleF = narrow<GLfloat>(yScale);
45 GLfloat scan_a = (yScale & 1) ? 0.5f : ((yScaleF + 1.0f) / (2.0f * yScaleF));
46 GLfloat scan_b = 2.0f - 2.0f * scanline;
47 GLfloat scan_c = scanline;
54 auto recipSrcWidth = 1.0f / narrow<float>(srcWidth);
55 glUniform3f(unifTexStepX[i], recipSrcWidth, recipSrcWidth, 0.0f);
56 glUniform4f(unifCnst[i], scan_a, scan_b, scan_c, blur);
59 srcStartY, srcEndY, srcWidth,
60 dstStartY, dstEndY, dstWidth,
65 fallback.
scaleImage(src, superImpose, srcStartY, srcEndY, srcWidth,
66 dstStartY, dstEndY, dstWidth, logSrcHeight);
void setInterpolation(bool interpolation)
Enable/disable bilinear interpolation for this texture.
Abstract base class for OpenGL scalers.
void setup(bool superImpose)
Setup scaler.
std::array< gl::ShaderProgram, 2 > program
void execute(const gl::ColorTexture &src, const gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight, bool textureFromZero=false)
Helper method to draw a rectangle with multiple texture coordinates.
virtual void scaleImage(gl::ColorTexture &src, gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight)=0
Scales the image in the given area, which must consist of lines which are all equally wide.
GLSimpleScaler(RenderSettings &renderSettings, GLScaler &fallback)
void scaleImage(gl::ColorTexture &src, gl::ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight) override
Scales the image in the given area, which must consist of lines which are all equally wide.
Class containing all settings for renderers.
int getScanlineFactor() const
int getBlurFactor() const
This file implemented 3 utility functions:
constexpr auto xrange(T e)