33 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
39 #define G4DEBUG_VIS_OGL 1
41 G4OpenGLImmediateWtViewer::G4OpenGLImmediateWtViewer
42 (G4OpenGLImmediateSceneHandler& sceneHandler,
43 Wt::WContainerWidget* aParent,
45 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
46 G4OpenGLViewer (sceneHandler),
47 G4OpenGLWtViewer (sceneHandler),
48 G4OpenGLImmediateViewer (sceneHandler),
49 Wt::WGLWidget(aParent)
54 setVboDrawer(
new G4OpenGLVboDrawer(
this,
"OGL-ES"));
57 aParent->addWidget(
this);
59 fHasToRepaint =
false;
60 fIsRepainting =
false;
62 #ifdef G4DEBUG_VIS_OGL
63 printf(
"G4OpenGLImmediateWtViewer INIT\n");
67 if (fViewId < 0)
return;
70 G4OpenGLImmediateWtViewer::~G4OpenGLImmediateWtViewer() {
73 void G4OpenGLImmediateWtViewer::Initialise() {
74 #ifdef G4DEBUG_VIS_OGL
75 printf(
"G4OpenGLImmediateWtViewer::Initialise \n");
77 fReadyToPaint =
false;
78 CreateMainWindow (
this,Wt::WString(
fName));
84 void G4OpenGLImmediateWtViewer::initializeGL () {
92 if (fSceneHandler.GetScene() == 0) {
104 Wt::WMatrix4x4 worldTransform;
105 worldTransform.lookAt(
113 jsMatrix_ = createJavaScriptMatrix4();
114 setJavaScriptMatrix4(jsMatrix_, worldTransform);
120 setClientSideLookAtHandler(jsMatrix_,
130 glClearColor(0, 0, 0, 0);
134 glEnable(DEPTH_TEST);
136 #ifdef G4DEBUG_VIS_OGL
137 printf(
"G4OpenGLWtViewer initializeGL END\n");
145 void G4OpenGLImmediateWtViewer::DrawView() {
150 void G4OpenGLImmediateWtViewer::ComputeView () {
152 #ifdef G4DEBUG_VIS_OGL
153 printf(
"G4OpenGLWtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
169 #ifdef G4DEBUG_VIS_OGL
170 printf(
"G4OpenGLWtViewer::ComputeView First ProcessView ok\n");
172 HaloingSecondPass ();
185 #ifdef G4DEBUG_VIS_OGL
186 printf(
"G4OpenGLWtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
188 fHasToRepaint =
true;
194 void G4OpenGLImmediateWtViewer::resizeGL(
198 #ifdef G4DEBUG_VIS_OGL
199 printf(
"G4OpenGLImmediateWtViewer resizeGL %d %d\n",width,height);
201 G4OpenGLWtViewer::resizeGL(width,height);
204 glViewport(0, 0, width, height);
216 void G4OpenGLImmediateWtViewer::paintGL() {
221 if (!fReadyToPaint) {
225 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
230 if ( !fHasToRepaint) {
234 sw =
width().value();
235 sh = height().value();
240 if ((getWinWidth() == sw) &&(getWinHeight() == sh)) {
243 }
else if ((sw == 0) && (sh == 0)) {
244 if (((getWinWidth() ==
width().
value())) &&(getWinHeight() == height().
value())) {
249 #ifdef G4DEBUG_VIS_OGL
250 printf(
"G4OpenGLImmediateWtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
263 glUniformMatrix4(fcMatrixUniform, jsMatrix_);
266 Wt::WMatrix4x4 modelMatrix;
267 glUniformMatrix4(fmvMatrixUniform, modelMatrix);
278 glUniformMatrix4(fnMatrixUniform, (jsMatrix_ * modelMatrix).inverted().transposed());
281 Buffer objBuffer_2 = glCreateBuffer();
284 glBindBuffer(GL_ARRAY_BUFFER, objBuffer_2);
290 fHasToRepaint =
false;
292 #ifdef G4DEBUG_VIS_OGL
293 printf(
"G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n\n\n",fReadyToPaint);
295 fIsRepainting =
false;
300 void G4OpenGLImmediateWtViewer::mousePressEvent(Wt::WMouseEvent *event)
303 G4MousePressEvent(event);
306 void G4OpenGLImmediateWtViewer::keyPressEvent (Wt::WKeyEvent *event)
308 G4keyPressEvent(event);
323 void G4OpenGLImmediateWtViewer::mouseDoubleClickEvent(Wt::WMouseEvent *)
325 G4MouseDoubleClickEvent();
329 void G4OpenGLImmediateWtViewer::mouseReleaseEvent(Wt::WMouseEvent )
331 G4MouseReleaseEvent();
335 void G4OpenGLImmediateWtViewer::mouseMoveEvent(Wt::WMouseEvent *event)
337 G4MouseMoveEvent(event);
348 void G4OpenGLImmediateWtViewer::paintEvent(Wt::WPaintDevice * ) {
349 if ( fHasToRepaint) {
356 void G4OpenGLImmediateWtViewer::FinishView()
358 #ifdef G4DEBUG_VIS_OGL
359 printf(
"G4OpenGLWtViewer::FinishView() \n");
369 void G4OpenGLImmediateWtViewer::popMatrix() {
372 void G4OpenGLImmediateWtViewer::pushMatrix() {
375 void G4OpenGLImmediateWtViewer::multMatrixd(
const GLdouble* ) {
379 void G4OpenGLImmediateWtViewer::loadIdentity() {
380 mMatrix.setToIdentity ();
384 void G4OpenGLImmediateWtViewer::setMatrixUniforms() {
395 void G4OpenGLImmediateWtViewer::ShowView (
400 #ifdef G4DEBUG_VIS_OGL
401 printf(
"G4OpenGLImmediateWtViewer ShowView\n");
408 void G4OpenGLImmediateWtViewer::updateWWidget() {
409 #ifdef G4DEBUG_VIS_OGL
410 printf(
"G4OpenGLImmediateWtViewer updateWWidget\n");
414 repaintGL(PAINT_GL | RESIZE_GL);
416 fHasToRepaint=
false;
417 #ifdef G4DEBUG_VIS_OGL
418 printf(
"G4OpenGLImmediateWtViewer updateWWidget END\n");
const XML_Char int const XML_Char * value