Project

General

Profile

Support #6960 ยป paintedSignal.patch

Roel Standaert, 05/27/2019 10:21 AM

View differences:

examples/webgl/PaintWidget.C
}
PaintWidget::PaintWidget(const bool & useBinaryBuffers):
WGLWidget(), initialized_(false), useBinaryBuffers_(useBinaryBuffers)
WGLWidget(),
initialized_(false),
painted_(this, "painted"),
useBinaryBuffers_(useBinaryBuffers)
{
jsMatrix_ = JavaScriptMatrix4x4();
addJavaScriptMatrix4(jsMatrix_);
painted_.connect([]{
std::cout << "painted!\n";
});
doJavaScript(jsRef() + ".firstRender=true;");
}
// The initializeGL() captures all JS commands that are to be executed
......
// Now draw all the triangles.
drawArrays(TRIANGLES, 0, data.size()/6);
injectJS("if(" + jsRef() + ".firstRender){"
"" + jsRef() + ".firstRender=false;"
"" + painted_.createCall({}) +
"}");
}
void PaintWidget::setShaders(const std::string &vertexShader,
examples/webgl/PaintWidget.h
#define PAINTWIDGET_H_
#include <Wt/WGLWidget.h>
#include <Wt/WJavaScript.h>
using namespace Wt;
......
std::string vertexShader_;
std::string fragmentShader_;
JSignal<> painted_;
// Program and related variables
Program shaderProgram_;
AttribLocation vertexPositionAttribute_;
    (1-1/1)