Render to framebuffer object.
40 using namespace visual;
53 visual::Session *_sessionViz =
54 const_cast<omni::Session&
>(_tuning.session()).makeVisualizer();
55 visual::Tuning *_tuningViz =
const_cast<proj::Tuning&
>(_tuning).makeVisualizer();
57 static ContextBoundPtr<Framebuffer32F> _warpBuffer;
58 static ContextBoundPtr<Framebuffer32F> _blendBuffer;
60 static ContextBoundPtr<QOpenGLShaderProgram> _mergeShader;
61 static ContextBoundPtr<QOpenGLShaderProgram> _shader;
66 _sessionViz->update();
68 _tuningViz->updateWarpBuffer(_sessionViz);
69 _tuningViz->updateBlendTexture();
79 auto _initFramebuffer = [&](ContextBoundPtr<Framebuffer32F>& _fb) {
80 bool _reset = _fb ? _fb->size() != _size :
true;
82 _fb.reset(
new Framebuffer32F(_size));
85 _initFramebuffer(_warpBuffer);
86 _initFramebuffer(_blendBuffer);
87 _initFramebuffer(_framebuffer);
96 glMultMatrixf(_tuning.projector().projectionMatrix().constData());
97 }, [&](QOpenGLFunctions& _) {
99 _.glClearColor(0.0,0.0,1.0,1.0);
100 _.glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
101 _.glEnable(GL_BLEND);
102 _.glEnable(GL_DEPTH_TEST);
103 _sessionViz->drawCanvas(_tuning.session().exportSettings().
104 mappingOutputMode());
105 _.glClearColor(0.0,0.0,0.0,0.0);
112 QOpenGLFunctions& _) {
115 _m.ortho(-0.5, 0.5, -0.5, 0.5, -1.0, 1.0);
116 glMultMatrixf(_m.constData()); }, [&](QOpenGLFunctions& _) {
117 _.glEnable(GL_BLEND);
118 _.glDisable(GL_DEPTH_TEST);
120 GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
122 _tuningViz->drawOutput();
128 QOpenGLFunctions& _) {
131 _m.ortho(-0.5, 0.5, -0.5, 0.5, -1.0, 1.0);
132 glMultMatrixf(_m.constData());
133 }, [&](QOpenGLFunctions& _) {
134 _.glEnable(GL_BLEND);
135 _.glDisable(GL_DEPTH_TEST);
137 GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
139 useShader(*_shader, [&](visual::UniformHandler& _h) {
140 _h.texUniform(
"tex", _framebuffer->texture());
141 _tuningViz->drawWarpPatch();
150 _m.ortho(-0.5, 0.5, -0.5, 0.5, -1.0, 1.0);
151 glMultMatrixf(_m.constData());
153 }, [&](QOpenGLFunctions& _) {
154 _.glEnable(GL_BLEND);
155 _.glDisable(GL_DEPTH_TEST);
157 GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
159 useShader(*_mergeShader, [&](visual::UniformHandler& _h) {
160 _h.texUniform(
"warp", _warpBuffer->texture());
161 _h.texUniform(
"blend", _blendBuffer->texture());
void draw_on_framebuffer(FRAMEBUFFER *_f, PROJECTION _p, MODELVIEW _m)
Draw into QOpenGLFramebufferObject with given projection and model.
Definition: util.h:103
A session consists of a canvas, a mapping, a list of tunings and one or several inputs.
Definition: Session.h:41
QRect screenGeometry_
Definition: Calibration.h:109
int height() const
Return height of the buffer.
Definition: Buffer.h:137
void initShader(QOpenGLShaderProgram &_s, const char *_filename)
Initialize shader: load from file and compile.
Definition: Shader.cpp:27
QRect contentGeometry_
Definition: Calibration.h:110
RenderBuffer buffer_
Definition: Calibration.h:113
bool virtualScreen_
Definition: Calibration.h:108
static void draw(float _left=-0.5, float _right=0.5, float _top=0.5, float _bottom=-0.5)
Draw rectangle from border coordinates.
Definition: Rectangle.cpp:28
void useShader(QOpenGLShaderProgram &_s, std::function< void(UniformHandler &)>f)
Use shader with and do uniform assignment and drawing inside functor.
Definition: Shader.cpp:59
void resize(int _width, int _height)
Resize buffer to given width and height.
Definition: Buffer.h:172
ColorCorrection colorCorrection_
Definition: Calibration.h:112
void primaryContextSwitch(ContextFunctor f)
Switch to primary context to create OpenGL objects like textures etc.
Definition: ContextSwitch.cpp:40
int width() const
Return width of the buffer.
Definition: Buffer.h:131