openMSX
GLSaIScaler.cc
Go to the documentation of this file.
1 #include "GLSaIScaler.hh"
2 
3 using std::string;
4 
5 namespace openmsx {
6 
8 {
9  for (int i = 0; i < 2; ++i) {
10  string header = string("#define SUPERIMPOSE ")
11  + char('0' + i) + '\n';
12  VertexShader vertexShader (header, "sai.vert");
13  FragmentShader fragmentShader(header, "sai.frag");
14  scalerProgram[i].attach(vertexShader);
15  scalerProgram[i].attach(fragmentShader);
16  scalerProgram[i].link();
17 
18  scalerProgram[i].activate();
19  glUniform1i(scalerProgram[i].getUniformLocation("tex"), 0);
20  if (i == 1) {
21  glUniform1i(scalerProgram[i].getUniformLocation("videoTex"), 1);
22  }
23  texSizeLoc[i] = scalerProgram[i].getUniformLocation("texSize");
24  }
25 }
26 
28  ColorTexture& src, ColorTexture* superImpose,
29  unsigned srcStartY, unsigned srcEndY, unsigned srcWidth,
30  unsigned dstStartY, unsigned dstEndY, unsigned dstWidth,
31  unsigned logSrcHeight)
32 {
33  int i = superImpose ? 1 : 0;
34  if (superImpose) {
35  glActiveTexture(GL_TEXTURE1);
36  superImpose->bind();
37  glActiveTexture(GL_TEXTURE0);
38  }
39  scalerProgram[i].activate();
40  glUniform2f(texSizeLoc[i], srcWidth, src.getHeight());
41  drawMultiTex(src, srcStartY, srcEndY, src.getHeight(), logSrcHeight,
42  dstStartY, dstEndY, dstWidth);
43 }
44 
45 } // namespace openmsx
Wrapper around an OpenGL fragment shader: a program executed on the GPU that computes the colors of p...
Definition: GLUtil.hh:426
Wrapper around an OpenGL vertex shader: a program executed on the GPU that computes per-vertex stuff...
Definition: GLUtil.hh:413
void drawMultiTex(ColorTexture &src, unsigned srcStartY, unsigned srcEndY, float physSrcHeight, float logSrcHeight, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, bool textureFromZero=false)
Helper method to draw a rectangle with multiple texture coordinates.
Definition: GLScaler.cc:48
void activate() const
Makes this program the active shader program.
Definition: GLUtil.cc:383
void link()
Links all attached shaders together into one program.
Definition: GLUtil.cc:346
GLint getUniformLocation(const char *name) const
Gets a reference to a uniform variable declared in the shader source.
Definition: GLUtil.cc:366
void bind()
Makes this texture the active GL texture.
Definition: GLUtil.hh:61
GLsizei getHeight() const
Definition: GLUtil.hh:119
void attach(const Shader &shader)
Adds a given shader to this program.
Definition: GLUtil.cc:334
virtual void scaleImage(ColorTexture &src, ColorTexture *superImpose, unsigned srcStartY, unsigned srcEndY, unsigned srcWidth, unsigned dstStartY, unsigned dstEndY, unsigned dstWidth, unsigned logSrcHeight)
Scales the image in the given area, which must consist of lines which are all equally wide...
Definition: GLSaIScaler.cc:27