Support #6960 ยป paintedSignal.patch
examples/webgl/PaintWidget.C | ||
---|---|---|
36 | 36 |
} |
37 | 37 | |
38 | 38 |
PaintWidget::PaintWidget(const bool & useBinaryBuffers): |
39 |
WGLWidget(), initialized_(false), useBinaryBuffers_(useBinaryBuffers) |
|
39 |
WGLWidget(), |
|
40 |
initialized_(false), |
|
41 |
painted_(this, "painted"), |
|
42 |
useBinaryBuffers_(useBinaryBuffers) |
|
40 | 43 |
{ |
41 | 44 |
jsMatrix_ = JavaScriptMatrix4x4(); |
42 | 45 |
addJavaScriptMatrix4(jsMatrix_); |
46 | ||
47 |
painted_.connect([]{ |
|
48 |
std::cout << "painted!\n"; |
|
49 |
}); |
|
50 | ||
51 |
doJavaScript(jsRef() + ".firstRender=true;"); |
|
43 | 52 |
} |
44 | 53 | |
45 | 54 |
// The initializeGL() captures all JS commands that are to be executed |
... | ... | |
200 | 209 | |
201 | 210 |
// Now draw all the triangles. |
202 | 211 |
drawArrays(TRIANGLES, 0, data.size()/6); |
212 | ||
213 |
injectJS("if(" + jsRef() + ".firstRender){" |
|
214 |
"" + jsRef() + ".firstRender=false;" |
|
215 |
"" + painted_.createCall({}) + |
|
216 |
"}"); |
|
203 | 217 |
} |
204 | 218 | |
205 | 219 |
void PaintWidget::setShaders(const std::string &vertexShader, |
examples/webgl/PaintWidget.h | ||
---|---|---|
8 | 8 |
#define PAINTWIDGET_H_ |
9 | 9 | |
10 | 10 |
#include <Wt/WGLWidget.h> |
11 |
#include <Wt/WJavaScript.h> |
|
11 | 12 | |
12 | 13 |
using namespace Wt; |
13 | 14 | |
... | ... | |
37 | 38 |
std::string vertexShader_; |
38 | 39 |
std::string fragmentShader_; |
39 | 40 | |
41 |
JSignal<> painted_; |
|
42 | ||
40 | 43 |
// Program and related variables |
41 | 44 |
Program shaderProgram_; |
42 | 45 |
AttribLocation vertexPositionAttribute_; |