1 #include <msp/gl/meshbuilder.h>
2 #include <msp/gl/texture2d.h>
3 #include "sidebysidecombiner.h"
7 const char vs_source[] =
8 "uniform float offset;\n"
9 "varying vec2 texcoord;\n"
12 " gl_Position = vec4(gl_Vertex.x*0.5+offset, gl_Vertex.yzw);\n"
13 " texcoord = gl_Vertex.xy*0.5+0.5;\n"
16 const char fs_source[] =
17 "uniform sampler2D texture;\n"
18 "varying vec2 texcoord;\n"
21 " gl_FragColor = texture2D(texture, texcoord);\n"
29 SideBySideCombiner::SideBySideCombiner(bool c):
31 shprog(vs_source, fs_source)
35 left_shdata.uniform("texture", 0);
36 right_shdata.uniform("texture", 0);
40 GL::MeshBuilder bld(mesh);
41 bld.begin(GL::TRIANGLE_STRIP);
49 void SideBySideCombiner::set_cross_eyed(bool c)
52 float m = (cross_eyed ? -0.5f : 0.5f);
53 left_shdata.uniform("offset", -m);
54 right_shdata.uniform("offset", m);
57 void SideBySideCombiner::render(const GL::Texture2D &left, const GL::Texture2D &right) const
59 GL::Bind bind_shprog(shprog);
61 GL::Bind bind_tex(left);