32 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
38 #define G4DEBUG_VIS_OGL 1
40 G4OpenGLImmediateWtViewer::G4OpenGLImmediateWtViewer
41 (G4OpenGLImmediateSceneHandler& sceneHandler,
42 Wt::WContainerWidget* aParent,
44 G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45 G4OpenGLViewer (sceneHandler),
46 G4OpenGLWtViewer (sceneHandler),
47 G4OpenGLImmediateViewer (sceneHandler),
48 Wt::WGLWidget(aParent)
53 setVboDrawer(
new G4OpenGLVboDrawer(
this,
"OGL-ES"));
56 aParent->addWidget(
this);
58 fHasToRepaint =
false;
59 fIsRepainting =
false;
61 #ifdef G4DEBUG_VIS_OGL
62 printf(
"G4OpenGLImmediateWtViewer INIT\n");
66 if (fViewId < 0)
return;
69 G4OpenGLImmediateWtViewer::~G4OpenGLImmediateWtViewer() {
72 void G4OpenGLImmediateWtViewer::Initialise() {
73 #ifdef G4DEBUG_VIS_OGL
74 printf(
"G4OpenGLImmediateWtViewer::Initialise \n");
76 fReadyToPaint =
false;
77 CreateMainWindow (
this,Wt::WString(
fName));
83 void G4OpenGLImmediateWtViewer::initializeGL () {
91 if (fSceneHandler.GetScene() == 0) {
103 Wt::WMatrix4x4 worldTransform;
104 worldTransform.lookAt(
112 jsMatrix_ = createJavaScriptMatrix4();
113 setJavaScriptMatrix4(jsMatrix_, worldTransform);
119 setClientSideLookAtHandler(jsMatrix_,
129 glClearColor(0, 0, 0, 0);
133 glEnable(DEPTH_TEST);
135 #ifdef G4DEBUG_VIS_OGL
136 printf(
"G4OpenGLWtViewer initializeGL END\n");
144 void G4OpenGLImmediateWtViewer::DrawView() {
149 void G4OpenGLImmediateWtViewer::ComputeView () {
151 #ifdef G4DEBUG_VIS_OGL
152 printf(
"G4OpenGLWtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
168 #ifdef G4DEBUG_VIS_OGL
169 printf(
"G4OpenGLWtViewer::ComputeView First ProcessView ok\n");
171 HaloingSecondPass ();
184 #ifdef G4DEBUG_VIS_OGL
185 printf(
"G4OpenGLWtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
187 fHasToRepaint =
true;
193 void G4OpenGLImmediateWtViewer::resizeGL(
197 #ifdef G4DEBUG_VIS_OGL
198 printf(
"G4OpenGLImmediateWtViewer resizeGL %d %d\n",width,height);
200 G4OpenGLWtViewer::resizeGL(width,height);
203 glViewport(0, 0, width, height);
215 void G4OpenGLImmediateWtViewer::paintGL() {
220 if (!fReadyToPaint) {
224 if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
229 if ( !fHasToRepaint) {
233 sw =
width().value();
234 sh = height().value();
239 if ((getWinWidth() == sw) &&(getWinHeight() == sh)) {
242 }
else if ((sw == 0) && (sh == 0)) {
243 if (((getWinWidth() ==
width().
value())) &&(getWinHeight() == height().
value())) {
248 #ifdef G4DEBUG_VIS_OGL
249 printf(
"G4OpenGLImmediateWtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
262 glUniformMatrix4(fcMatrixUniform, jsMatrix_);
265 Wt::WMatrix4x4 modelMatrix;
266 glUniformMatrix4(fmvMatrixUniform, modelMatrix);
277 glUniformMatrix4(fnMatrixUniform, (jsMatrix_ * modelMatrix).inverted().transposed());
280 Buffer objBuffer_2 = glCreateBuffer();
283 glBindBuffer(GL_ARRAY_BUFFER, objBuffer_2);
289 fHasToRepaint =
false;
291 #ifdef G4DEBUG_VIS_OGL
292 printf(
"G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n\n\n",fReadyToPaint);
294 fIsRepainting =
false;
299 void G4OpenGLImmediateWtViewer::mousePressEvent(Wt::WMouseEvent *event)
302 G4MousePressEvent(event);
305 void G4OpenGLImmediateWtViewer::keyPressEvent (Wt::WKeyEvent *event)
307 G4keyPressEvent(event);
322 void G4OpenGLImmediateWtViewer::mouseDoubleClickEvent(Wt::WMouseEvent *)
324 G4MouseDoubleClickEvent();
328 void G4OpenGLImmediateWtViewer::mouseReleaseEvent(Wt::WMouseEvent )
330 G4MouseReleaseEvent();
334 void G4OpenGLImmediateWtViewer::mouseMoveEvent(Wt::WMouseEvent *event)
336 G4MouseMoveEvent(event);
347 void G4OpenGLImmediateWtViewer::paintEvent(Wt::WPaintDevice * ) {
348 if ( fHasToRepaint) {
355 void G4OpenGLImmediateWtViewer::FinishView()
357 #ifdef G4DEBUG_VIS_OGL
358 printf(
"G4OpenGLWtViewer::FinishView() \n");
368 void G4OpenGLImmediateWtViewer::popMatrix() {
371 void G4OpenGLImmediateWtViewer::pushMatrix() {
374 void G4OpenGLImmediateWtViewer::multMatrixd(
const GLdouble* ) {
378 void G4OpenGLImmediateWtViewer::loadIdentity() {
379 mMatrix.setToIdentity ();
383 void G4OpenGLImmediateWtViewer::setMatrixUniforms() {
394 void G4OpenGLImmediateWtViewer::ShowView (
399 #ifdef G4DEBUG_VIS_OGL
400 printf(
"G4OpenGLImmediateWtViewer ShowView\n");
407 void G4OpenGLImmediateWtViewer::updateWWidget() {
408 #ifdef G4DEBUG_VIS_OGL
409 printf(
"G4OpenGLImmediateWtViewer updateWWidget\n");
413 repaintGL(PAINT_GL | RESIZE_GL);
415 fHasToRepaint=
false;
416 #ifdef G4DEBUG_VIS_OGL
417 printf(
"G4OpenGLImmediateWtViewer updateWWidget END\n");