WebGLDemo::WebGLDemo(const WEnvironment& env) : WApplication(env) { setTitle("WebGL Demo"); root()->addWidget(new WText("This is a preliminary WebGL demo. It will " "become more spectacular in time. This technology preview has only " "been tested on Chrome Canary builds. No 3D because I did " "not yet invest in 3D projection matrices.")); root()->addWidget(new WBreak()); PaintWidget *gl = new PaintWidget(root()); gl->resize(640, 640); }
void WebGLDemo::updateShaders() { // check if binary buffers are enabled // i.e. if your application url is "webgl" on localhost:8080, use this to enable binary buffers: // localhost:8080/webgl?binaryBuffers // query given URL arguments... Http::ParameterValues pv = wApp->environment().getParameterValues("binaryBuffers"); bool useBinaryBuffers = false; if (!pv.empty()) { useBinaryBuffers = true; } delete paintWidget_; paintWidget_ = new PaintWidget(glContainer_, useBinaryBuffers); paintWidget_->resize(500, 500); paintWidget_->setShaders(vertexShaderText_->text().toUTF8(), fragmentShaderText_->text().toUTF8()); paintWidget_->setAlternativeContent(new WImage("nowebgl.png")); }