Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4OpenGLImmediateWtViewer.cc
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4OpenGLImmediateWtViewer.cc 75567 2013-11-04 11:35:11Z gcosmo $
28 //
29 //
30 // Class G4OpenGLImmediateWtViewer : a class derived from G4OpenGLWtViewer and
31 // G4OpenGLImmediateViewer.
32 
33 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
34 
37 
38 #include "G4ios.hh"
39 
40 G4OpenGLImmediateWtViewer::G4OpenGLImmediateWtViewer
41 (G4OpenGLImmediateSceneHandler& sceneHandler,
42  Wt::WContainerWidget* aParent,
43  const G4String& name):
44  G4VViewer (sceneHandler, sceneHandler.IncrementViewCount (), name),
45  G4OpenGLViewer (sceneHandler),
46  G4OpenGLWtViewer (sceneHandler),
47  G4OpenGLImmediateViewer (sceneHandler),
48  Wt::WGLWidget(aParent)
49 
50 {
51 // Create a new drawer
52  fWtDrawer = new G4OpenGLWtDrawer(this);
53 
54  // register the WtDrawer to the OpenGLViewer
55  setWtDrawer(fWtDrawer);
56 
57  // Add the GL Widget to its parent
58  aParent->addWidget(this);
59 
60  fHasToRepaint = false;
61  fIsRepainting = false;
62 
63 #ifdef G4DEBUG_VIS_OGL
64  printf("G4OpenGLImmediateWtViewer INIT\n");
65 #endif
66 
67 
68  if (fViewId < 0) return; // In case error in base class instantiation.
69 }
70 
71 G4OpenGLImmediateWtViewer::~G4OpenGLImmediateWtViewer() {
72 }
73 
74 void G4OpenGLImmediateWtViewer::Initialise() {
75 #ifdef G4DEBUG_VIS_OGL
76  printf("G4OpenGLImmediateWtViewer::Initialise \n");
77 #endif
78  fReadyToPaint = false;
79  CreateMainWindow (this,Wt::WString(fName));
80  CreateFontLists ();
81 
82  fReadyToPaint = true;
83 }
84 
85 void G4OpenGLImmediateWtViewer::initializeGL () {
86 
87  InitializeGLView ();
88 
89  // If a double buffer context has been forced upon us, ignore the
90  // back buffer for this OpenGLImmediate view.
91  // glDrawBuffer (GL_FRONT); // FIXME : Ne marche pas avec cette ligne, mais affiche le run correctement...
92 
93  if (fSceneHandler.GetScene() == 0) {
94  fHasToRepaint =false;
95  } else {
96  fHasToRepaint =true;
97  }
98 
99  // In order to know where to look at, calculate the centerpoint of the
100  // scene
101  double cx, cy, cz;
102  cx = cy = cz = 0.;
103 
104  // Transform the world so that we look at the centerpoint of the scene
105  Wt::WMatrix4x4 worldTransform;
106  worldTransform.lookAt(
107  cx, cy, cz + 10, // camera position
108  cx, cy, cz, // looking at
109  0, 1, 0); // 'up' vector
110 
111  // We want to be able to change the camera position client-side. In
112  // order to do so, the world transformation matrix must be stored in
113  // a matrix that can be manipulated from JavaScript.
114  jsMatrix_ = createJavaScriptMatrix4();
115  setJavaScriptMatrix4(jsMatrix_, worldTransform);
116 
117  // This installs a client-side mouse handler that modifies the
118  // world transformation matrix. Like WMatrix4x4::lookAt, this works
119  // by specifying a center point and an up direction; mouse movements
120  // will allow the camera to be moved around the center point.
121  setClientSideLookAtHandler(jsMatrix_, // the name of the JS matrix
122  cx, cy, cz, // the center point
123  0, 1, 0, // the up direction
124  0.005, 0.005); // 'speed' factors
125  // Alternative: this installs a client-side mouse handler that allows
126  // to 'walk' around: go forward, backward, turn left, turn right, ...
127  //setClientSideWalkHandler(jsMatrix_, 0.05, 0.005);
128 
129 
130  // Set the clear color to a transparant background
131  glClearColor(0, 0, 0, 0);
132 
133  // Reset Z-buffer, enable Z-buffering
134  glClearDepth(1);
135  glEnable(DEPTH_TEST);
136  glDepthFunc(LEQUAL);
137 #ifdef G4DEBUG_VIS_OGL
138  printf("G4OpenGLWtViewer initializeGL END\n");
139 #endif
140 
141  // Set the component visible
142  show() ;
143 
144 }
145 
146 void G4OpenGLImmediateWtViewer::DrawView() {
147  updateWWidget();
148 }
149 
150 
151 void G4OpenGLImmediateWtViewer::ComputeView () {
152 
153 #ifdef G4DEBUG_VIS_OGL
154  printf("G4OpenGLWtViewer::ComputeView %d %d VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV\n",getWinWidth(), getWinHeight());
155 #endif
156 
157  // If a double buffer context has been forced upon us, ignore the
158  // back buffer for this OpenGL view.
159  // glDrawBuffer (GL_FRONT);
160 
161  G4ViewParameters::DrawingStyle dstyle = GetViewParameters().GetDrawingStyle();
162 
163  if(dstyle!=G4ViewParameters::hlr &&
164  haloing_enabled) {
165 
166  HaloingFirstPass ();
167  NeedKernelVisit ();
168  ProcessView ();
169  FinishView();
170 #ifdef G4DEBUG_VIS_OGL
171  printf("G4OpenGLWtViewer::ComputeView First ProcessView ok\n");
172 #endif
173  HaloingSecondPass ();
174 
175  }
176 
177  NeedKernelVisit (); // Always need to visit G4 kernel.
178  ProcessView ();
179 
180 /* FIXME
181  if (isRecording()) {
182  savePPMToTemp();
183  }
184  */
185 
186 #ifdef G4DEBUG_VIS_OGL
187  printf("G4OpenGLWtViewer::ComputeView %d %d ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",getWinWidth(), getWinHeight());
188 #endif
189  fHasToRepaint = true;
190 }
191 
192 /**
193  - Lors du resize de la fenetre, on doit non pas redessiner le detecteur, mais aussi les evenements
194  */
195 void G4OpenGLImmediateWtViewer::resizeGL(
196  int width
197 ,int height)
198 {
199 #ifdef G4DEBUG_VIS_OGL
200  printf("G4OpenGLImmediateWtViewer resizeGL %d %d\n",width,height);
201 #endif
202  G4OpenGLWtViewer::resizeGL(width,height);
203 
204  // Set the viewport size.
205  glViewport(0, 0, width, height);
206 
207  // Set projection matrix to some fixed values
208  Wt::WMatrix4x4 proj;
209  proj.perspective(45, ((double)width)/height, 1, 40);
210  glUniformMatrix4(pMatrixUniform_, proj);
211  // updateWWidget();
212 }
213 
214 
215 void G4OpenGLImmediateWtViewer::paintGL() {
216 // FIXME : for test
217  glClearColor(0.1234, 0.1234, 0.1234, 0.1234);
218 
219  if (fIsRepainting) {
220  // return ;
221  }
222  if (!fReadyToPaint) {
223  fReadyToPaint= true;
224  return;
225  }
226  if ((getWinWidth() == 0) && (getWinHeight() == 0)) {
227  return;
228  }
229 
230  // DO NOT RESIZE IF SIZE HAS NOT CHANGE
231  if ( !fHasToRepaint) {
232  double sw = 0;
233  double sh = 0;
234  // if (!isMaximized() && !isFullScreen()) {
235  sw = width().value();
236  sh = height().value();
237  // } else {
238  // sw = frameGeometry().width();
239  // sh = frameGeometry().height();
240  // }
241  if ((getWinWidth() == sw) &&(getWinHeight() == sh)) {
242  return;
243 
244  } else if ((sw == 0) && (sh == 0)) { // NOT A TOP LEVEL WIDGET
245  if (((getWinWidth() == width().value())) &&(getWinHeight() == height().value())) {
246  return;
247  }
248  }
249  }
250 #ifdef G4DEBUG_VIS_OGL
251  printf("G4OpenGLImmediateWtViewer::paintGL VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ready %d\n",fReadyToPaint);
252 #endif
253 
254  SetView();
255 
256  ClearView(); //ok, put the background correct
257  drawScene();
258 
259  ComputeView();
260 
261  fHasToRepaint = false; // could be set to false by ComputeView
262 
263 #ifdef G4DEBUG_VIS_OGL
264  printf("G4OpenGLImmediateQtViewer::paintGL ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ready %d\n\n\n",fReadyToPaint);
265 #endif
266  fIsRepainting = false;
267  // FIXME : for test
268  glClearColor(0.1234, 0.1234, 0.1234, 0.1234);
269 }
270 
271 
272 void G4OpenGLImmediateWtViewer::mousePressEvent(Wt::WMouseEvent *event)
273 {
274  // boutons et position
275  G4MousePressEvent(event);
276 }
277 
278 void G4OpenGLImmediateWtViewer::keyPressEvent (Wt::WKeyEvent *event)
279 {
280  G4keyPressEvent(event);
281 }
282 
283 /**
284  void G4OpenGLImmediateWtViewer::showEvent (QShowEvent *)
285  {
286  fHasToRepaint = true;
287  }
288  */
289 
290 
291 /**
292  * This function was build in order to make a zoom on double clic event.
293  * It was think to build a rubberband on the zoom area, but never work fine
294  */
295 void G4OpenGLImmediateWtViewer::mouseDoubleClickEvent(Wt::WMouseEvent *)
296 {
297  G4MouseDoubleClickEvent();
298 }
299 
300 
301 void G4OpenGLImmediateWtViewer::mouseReleaseEvent(Wt::WMouseEvent )
302 {
303  G4MouseReleaseEvent();
304 }
305 
306 
307 void G4OpenGLImmediateWtViewer::mouseMoveEvent(Wt::WMouseEvent *event)
308 {
309  G4MouseMoveEvent(event);
310 }
311 
312 
313 /**
314  void G4OpenGLImmediateWtViewer::contextMenuEvent(QContextMenuEvent *e)
315  {
316  G4manageContextMenuEvent(e);
317  }
318  */
319 
320 void G4OpenGLImmediateWtViewer::paintEvent(Wt::WPaintDevice * /* painter */) {
321  if ( fHasToRepaint) {
322  updateGL();
323  }
324 }
325 
326 
327 
328 void G4OpenGLImmediateWtViewer::FinishView()
329 {
330 #ifdef G4DEBUG_VIS_OGL
331  printf("G4OpenGLWtViewer::FinishView() \n");
332 #endif
333  flush ();
334 
335  // L. Garnier 10/2009 : Not necessary and cause problems on mac OS X 10.6
336  // fWindow->swapBuffers ();
337 }
338 
339 
340 void G4OpenGLImmediateWtViewer::SetView () {
341 
342  if (!fSceneHandler.GetScene()) {
343  return;
344  }
345  // Calculates view representation based on extent of object being
346  // viewed and (initial) viewpoint. (Note: it can change later due
347  // to user interaction via visualization system's GUI.)
348 
349  /*
350  // Lighting.
351  GLfloat lightPosition [4];
352  lightPosition [0] = fVP.GetActualLightpointDirection().x();
353  lightPosition [1] = fVP.GetActualLightpointDirection().y();
354  lightPosition [2] = fVP.GetActualLightpointDirection().z();
355  lightPosition [3] = 0.;
356  // Light position is "true" light direction, so must come after gluLookAt.
357  GLfloat ambient [] = { 0.2, 0.2, 0.2, 1.};
358  GLfloat diffuse [] = { 0.8, 0.8, 0.8, 1.};
359 // enable (Wt::WGLWidget::LIGHT0);
360 
361  G4double ratioX = 1;
362  G4double ratioY = 1;
363  if (getWinHeight() > getWinWidth()) {
364  ratioX = ((G4double)getWinHeight()) / ((G4double)getWinWidth());
365  }
366  if (getWinWidth() > getWinHeight()) {
367  ratioY = ((G4double)getWinWidth()) / ((G4double)getWinHeight());
368  }
369 
370  // Get radius of scene, etc.
371  // Note that this procedure properly takes into account zoom, dolly and pan.
372  const G4Point3D targetPoint
373  = fSceneHandler.GetScene()->GetStandardTargetPoint()
374  + fVP.GetCurrentTargetPoint ();
375  G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius();
376  if(radius<=0.) radius = 1.;
377  const G4double cameraDistance = fVP.GetCameraDistance (radius);
378  const G4Point3D cameraPosition =
379  targetPoint + cameraDistance * fVP.GetViewpointDirection().unit();
380  const GLdouble pnear = fVP.GetNearDistance (cameraDistance, radius);
381  const GLdouble pfar = fVP.GetFarDistance (cameraDistance, pnear, radius);
382  const GLdouble right = fVP.GetFrontHalfHeight (pnear, radius) * ratioY;
383  const GLdouble left = -right;
384  const GLdouble top = fVP.GetFrontHalfHeight (pnear, radius) * ratioX;
385  const GLdouble bottom = -top;
386  */
387  // FIXME
388 // ResizeGLView();
389 #ifdef G4DEBUG_VIS_OGL
390  printf("G4OpenGLWtViewer::SetView() resize viewport to %d %d\n",getWinWidth(),getWinHeight());
391 #endif
392  glViewport(0, 0, getWinWidth(),getWinHeight());
393  //SHOULD SetWindowsSizeHint()...
394 
395 /*
396  glMatrixMode (GL_PROJECTION); // set up Frustum.
397  glLoadIdentity();
398 
399  const G4Vector3D scaleFactor = fVP.GetScaleFactor();
400  glScaled(scaleFactor.x(),scaleFactor.y(),scaleFactor.z());
401  if (fVP.GetFieldHalfAngle() == 0.) {
402  glOrtho (left, right, bottom, top, pnear, pfar);
403  }
404  else {
405  glFrustum (left, right, bottom, top, pnear, pfar);
406  }
407 
408  glMatrixMode (GL_MODELVIEW); // apply further transformations to scene.
409  glLoadIdentity();
410 
411  const G4Normal3D& upVector = fVP.GetUpVector ();
412  G4Point3D gltarget;
413  if (cameraDistance > 1.e-6 * radius) {
414  gltarget = targetPoint;
415  }
416  else {
417  gltarget = targetPoint - radius * fVP.GetViewpointDirection().unit();
418  }
419 
420  const G4Point3D& pCamera = cameraPosition; // An alias for brevity.
421  gluLookAt (pCamera.x(), pCamera.y(), pCamera.z(), // Viewpoint.
422  gltarget.x(), gltarget.y(), gltarget.z(), // Target point.
423  upVector.x(), upVector.y(), upVector.z()); // Up vector.
424 
425  // Light position is "true" light direction, so must come after gluLookAt.
426  glLightfv (GL_LIGHT0, GL_POSITION, lightPosition);
427 
428  // OpenGL no longer seems to reconstruct clipped edges, so, when the
429  // BooleanProcessor is up to it, abandon this and use generic
430  // clipping in G4OpenGLSceneHandler::CreateSectionPolyhedron. Also,
431  // force kernel visit on change of clipping plane in
432  // G4OpenGLStoredViewer::CompareForKernelVisit.
433  //if (fVP.IsSection () ) { // pair of back to back clip planes.
434  if (false) { // pair of back to back clip planes.
435  const G4Plane3D& sp = fVP.GetSectionPlane ();
436  double sArray[4];
437  sArray[0] = sp.a();
438  sArray[1] = sp.b();
439  sArray[2] = sp.c();
440  sArray[3] = sp.d() + radius * 1.e-05;
441  glClipPlane (CLIP_PLANE0, sArray);
442  enable (Wt::WGLWidget::CLIP_PLANE0);
443  sArray[0] = -sp.a();
444  sArray[1] = -sp.b();
445  sArray[2] = -sp.c();
446  sArray[3] = -sp.d() + radius * 1.e-05;
447  glClipPlane (CLIP_PLANE1, sArray);
448  enable (Wt::WGLWidget::CLIP_PLANE1);
449  } else {
450  disable (Wt::WGLWidget::CLIP_PLANE0);
451  disable (Wt::WGLWidget::CLIP_PLANE1);
452  }
453 
454 */
455  // What we call intersection of cutaways is easy in OpenGL. You
456  // just keep cutting. Unions are more tricky - you have to have
457  // multiple passes and this is handled in
458  // G4OpenGLImmediate/StoredViewer::ProcessView.
459  const G4Planes& cutaways = fVP.GetCutawayPlanes();
460  size_t nPlanes = cutaways.size();
461  if (fVP.IsCutaway() &&
462  fVP.GetCutawayMode() == G4ViewParameters::cutawayIntersection &&
463  nPlanes > 0) {
464  double a[4];
465  a[0] = cutaways[0].a();
466  a[1] = cutaways[0].b();
467  a[2] = cutaways[0].c();
468  a[3] = cutaways[0].d();
469 /* glClipPlane (CLIP_PLANE2, a);
470  enable (Wt::WGLWidget::CLIP_PLANE2); */
471  if (nPlanes > 1) {
472  a[0] = cutaways[1].a();
473  a[1] = cutaways[1].b();
474  a[2] = cutaways[1].c();
475  a[3] = cutaways[1].d();
476 /* glClipPlane (CLIP_PLANE3, a);
477  enable (Wt::WGLWidget::CLIP_PLANE3); */
478  }
479  if (nPlanes > 2) {
480  a[0] = cutaways[2].a();
481  a[1] = cutaways[2].b();
482  a[2] = cutaways[2].c();
483  a[3] = cutaways[2].d();
484 /* glClipPlane (CLIP_PLANE4, a);
485  enable (Wt::WGLWidget::CLIP_PLANE4); */
486  }
487  } else {
488 /* disable (Wt::WGLWidget::CLIP_PLANE2);
489  disable (Wt::WGLWidget::CLIP_PLANE3);
490  disable (Wt::WGLWidget::CLIP_PLANE4); */
491  }
492 
493  // Background.
494  background = fVP.GetBackgroundColour ();
495 
496 }
497 
498 
499 void G4OpenGLImmediateWtViewer::popMatrix() {
500 }
501 
502 void G4OpenGLImmediateWtViewer::pushMatrix() {
503 }
504 
505 void G4OpenGLImmediateWtViewer::multMatrixd(const GLdouble* /* m */) {
506  // mMatrix = mMatrix * m;
507 }
508 
509 void G4OpenGLImmediateWtViewer::loadIdentity() {
510  mMatrix.setToIdentity ();
511 }
512 
513 
514 void G4OpenGLImmediateWtViewer::setMatrixUniforms() {
515  /*
516  UniformLocation pUniform = getUniformLocation(shaderProgram, "uPMatrix");
517  uniformMatrix4fv(pUniform, false, new Float32Array(perspectiveMatrix.flatten()));
518 
519  UniformLocation mvUniform = getUniformLocation(shaderProgram, "uMVMatrix");
520  uniformMatrix4fv(mvUniform, false, new Float32Array(mvMatrix.flatten()));
521  */
522 }
523 
524 void G4OpenGLImmediateWtViewer::wtDrawArrays(GLenum mode,int first,int nPoints, std::vector<double> a_vertices){
525  std::vector<double> data2;
526  for (int a=0; a< nPoints*3; a+=3) {
527  data2.push_back(a_vertices[a]);
528  data2.push_back(a_vertices[a+1]);
529  data2.push_back(a_vertices[a+2]);
530  data2.push_back(0);
531  data2.push_back(0);
532  data2.push_back(1);
533  }
534 
535  //----------------------------
536  // Fill VBO buffer
537  //----------------------------
538 
539  // Create a new Buffer
540  Buffer objBuffer_2 = glCreateBuffer(); //glGenBuffers(1,&objBuffer_2)
541 
542  VBO_Buffer.push_back(objBuffer_2);
543 
544  // Bind this buffer
545  glBindBuffer(GL_ARRAY_BUFFER, objBuffer_2);
546 
547  // Load data into VBO
548  glBufferDatafv(GL_ARRAY_BUFFER, data2.begin(), data2.end(), GL_STATIC_DRAW);
549 
550 
551  //----------------------------
552  // Draw VBO
553  //----------------------------
554  glBindBuffer(GL_ARRAY_BUFFER, objBuffer_2);
555 
556  // Configure the vertex attributes:
557  vertexAttribPointer(vertexPositionAttribute_,
558  3, // size: Every vertex has an X, Y anc Z component
559  GL_FLOAT, // type: They are floats
560  false, // normalized: Please, do NOT normalize the vertices
561  2*3*4, // stride: The first byte of the next vertex is located this
562  // amount of bytes further. The format of the VBO is
563  // vx, vy, vz, nx, ny, nz and every element is a
564  // Float32, hence 4 bytes large
565  0); // offset: The byte position of the first vertex in the buffer
566  // is 0.
567 
568  glDrawArrays(mode, first, data2.size()/6);
569 }
570 
571 
572 void G4OpenGLImmediateWtViewer::ShowView (
573 )
574 //////////////////////////////////////////////////////////////////////////////
575 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!//
576 {
577 #ifdef G4DEBUG_VIS_OGL
578  printf("G4OpenGLImmediateWtViewer ShowView\n");
579 #endif
580  repaintSlot();
581  // activateWindow();
582 }
583 
584 
585 void G4OpenGLImmediateWtViewer::updateWWidget() {
586 #ifdef G4DEBUG_VIS_OGL
587  printf("G4OpenGLImmediateWtViewer updateWWidget\n");
588 #endif
589  fHasToRepaint= true;
590  // updateGL();
591  repaintGL(PAINT_GL | RESIZE_GL);
592  // paintGL() ;
593  fHasToRepaint= false;
594 #ifdef G4DEBUG_VIS_OGL
595  printf("G4OpenGLImmediateWtViewer updateWWidget END\n");
596 #endif
597 }
598 
599 void G4OpenGLImmediateWtViewer::drawScene()
600 {
601  // Clear color an depth buffers
602  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
603 
604  // Configure the shader: set the uniforms
605  // Uniforms are 'configurable constants' in a shader: they are
606  // identical for every point that has to be drawn.
607  // Set the camera transformation to the value of a client-side JS matrix
608  glUniformMatrix4(cMatrixUniform_, jsMatrix_);
609  // Often, a model matrix is used to move the model around. We're happy
610  // with the location of the model, so we leave it as the unit matrix
611  Wt::WMatrix4x4 modelMatrix;
612  glUniformMatrix4(mvMatrixUniform_, modelMatrix);
613  // The next one is a bit complicated. In desktop OpenGL, a shader
614  // has the gl_NormalMatrix matrix available in the shader language,
615  // a matrix that is used to transform normals to e.g. implement proper
616  // Phong shading (google will help you to find a detailed explanation
617  // of why you need it). It is the transposed inverse of the model view
618  // matrix. Unfortunately, this matrix is not available in WebGL, so if
619  // you want to do phong shading, you must calculate it yourself.
620  // Wt provides methods to calculate the transposed inverse of a matrix,
621  // when client-side JS matrices are involved. Here, we inverse-transpose
622  // the product of the client-side camera matrix and the model matrix.
623  glUniformMatrix4(nMatrixUniform_, (jsMatrix_ * modelMatrix).inverted().transposed());
624 
625  // Configure the shaders: set the attributes.
626  // Attributes are 'variables' within a shader: they vary for every point
627  // that has to be drawn. All are stored in one VBO.
628 
629  // Create a Vertex Buffer Object (VBO) and load all polygon's data
630  // (points, normals) into it. In this case we use one VBO that contains
631  // all data (6 per point: vx, vy, vz, nx, ny, nz); alternatively you
632  // can use multiple VBO's (e.g. one VBO for normals, one for points,
633  // one for texture coordinates).
634  // Note that if you use indexed buffers, you cannot have indexes
635  // larger than 65K, due to the limitations of WebGL.
636 
637 
638 
639  /// LG : test
640  std::vector<double> vertices;
641  vertices.push_back(0);
642  vertices.push_back(0);
643  vertices.push_back(0);
644  vertices.push_back(10.);
645  vertices.push_back(0);
646  vertices.push_back(0);
647  vertices.push_back(0);
648  vertices.push_back(0);
649  vertices.push_back(0);
650  vertices.push_back(0);
651  vertices.push_back(10.);
652  vertices.push_back(0);
653  vertices.push_back(0);
654  vertices.push_back(0);
655  vertices.push_back(0);
656  vertices.push_back(0);
657  vertices.push_back(0);
658  vertices.push_back(10.);
659  wtDrawArrays(GL_LINES,0,6,vertices);
660 
661 #ifdef G4DEBUG_VIS_OGL
662  printf("G4OpenGLWtViewer drawScene Call ComputeView\n");
663 #endif
664 }
665 
666 
667 #endif
G4String fName
Definition: G4AttUtils.hh:55
#define width
const XML_Char * name
std::vector< G4Plane3D > G4Planes
const XML_Char int const XML_Char * value