Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4OpenGLVboDrawer.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: G4OpenGLVboDrawer.cc 74103 2013-09-23 07:52:38Z lgarnier $
28 //
29 //
30 // G4OpenGLWtViewer : Class to provide Vertex Buffer Object (VBO) specific
31 // functionality for OpenGL > 2.0 in GEANT4
32 //
33 
34 #include "G4OpenGLViewer.hh"
35 #ifdef G4OPENGL_VERSION_2
36 
37 #include "G4OpenGLVboDrawer.hh"
38 
39 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
41 #else
43 #endif
44 
45 
47 G4OpenGLVboDrawer::G4OpenGLVboDrawer (G4OpenGLViewer* viewer,
48  std::string type
49  ):
50 fVboViewer(NULL),
51 fOGLType(type)
54 {
55 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
56  G4OpenGLImmediateWtViewer* v = dynamic_cast<G4OpenGLImmediateWtViewer*>(viewer);
57 #else
58  G4OpenGLImmediateQtViewer* v = dynamic_cast<G4OpenGLImmediateQtViewer*>(viewer);
59 #endif
60  if (v) {
61  fVboViewer = v;
62  }
63 
64  fFragmentShaderSrc =
65  "#ifdef GL_ES\n"
66  "precision highp float;\n"
67  "#endif\n"
68  "\n"
69  "varying vec3 vLightWeighting;\n"
70  "uniform vec4 uPointColor; // Point Color\n"
71  "\n"
72  "void main(void) {\n"
73  " vec4 matColor = uPointColor;\n"
74  " gl_FragColor = vec4(matColor.rgb, matColor.a);\n"
75  "}\n";
76 
77 
78 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
79  fVertexShaderSrc =
80  "attribute vec3 aVertexPosition;\n"
81  "attribute vec3 aVertexNormal;\n"
82  "\n"
83  "uniform mat4 uMVMatrix; // [M]odel[V]iew matrix\n"
84  "uniform mat4 uCMatrix; // Client-side manipulated [C]amera matrix\n"
85  "uniform mat4 uPMatrix; // Perspective [P]rojection matrix\n"
86  "uniform mat4 uNMatrix; // [N]ormal transformation\n"
87  "// uNMatrix is the transpose of the inverse of uCMatrix * uMVMatrix\n"
88  "uniform mat4 uTMatrix; // [T]ransformation matrix\n"
89  "uniform float uPointSize; // Point size\n"
90  "\n"
91  "varying vec3 vLightWeighting;\n"
92  "\n"
93  "void main(void) {\n"
94  " // Calculate the position of this vertex\n"
95  " gl_Position = uPMatrix * uCMatrix * uMVMatrix * uTMatrix * vec4(aVertexPosition, 1.0);\n"
96  "\n"
97  " // Phong shading\n"
98  " vec3 transformedNormal = normalize((uNMatrix * vec4(normalize(aVertexNormal), 0)).xyz);\n"
99  " vec3 lightingDirection = normalize(vec3(1, 1, 1));\n"
100  " float directionalLightWeighting = max(dot(transformedNormal, lightingDirection), 0.0);\n"
101  " vec3 uAmbientLightColor = vec3(0.2, 0.2, 0.2);\n"
102  " vec3 uDirectionalColor = vec3(0.8, 0.8, 0.8);\n"
103  " gl_PointSize = uPointSize;\n"
104  " vLightWeighting = uAmbientLightColor + uDirectionalColor * directionalLightWeighting;\n"
105  "}\n";
106 
107 #else
108 
109 
110  fVertexShaderSrc =
111  "attribute highp vec4 aVertexPosition;\n"
112  "attribute vec3 aVertexNormal;\n"
113  "uniform highp mat4 uCMatrix;\n"
114  "uniform highp mat4 uPMatrix; // Perspective [P]rojection matrix\n"
115  "uniform highp mat4 uMVMatrix; // [M]odel[V]iew matrix\n"
116  "uniform highp mat4 uTMatrix; // [T]ransformation matrix\n"
117  "uniform float uPointSize; // Point size\n"
118  "void main(void)\n"
119  "{\n"
120  " gl_Position = uPMatrix * uCMatrix * uMVMatrix * uTMatrix * aVertexPosition;\n"
121  " // Phong shading\n"
122  // " vec3 transformedNormal = normalize((uNMatrix * vec4(normalize(aVertexNormal), 0)).xyz);\n"
123  " vec3 lightingDirection = normalize(vec3(1, 1, 1));\n"
124  // " float directionalLightWeighting = max(dot(transformedNormal, lightingDirection), 0.0);\n"
125  // " vec3 uAmbientLightColor = vec3(0.2, 0.2, 0.2);\n"
126  // " vec3 uDirectionalColor = vec3(0.8, 0.8, 0.8);\n"
127  " gl_PointSize = uPointSize;\n"
128  // " vLightWeighting = uAmbientLightColor + uDirectionalColor * directionalLightWeighting;\n"
129  "}";
130 #endif
131 
132 
133 }
134 
136 G4OpenGLVboDrawer::~G4OpenGLVboDrawer (
137 )
140 {
141 }
142 // +--------------------------------+
143 // + WT (OpenGL ES) case +
144 // +--------------------------------+
145 
146 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
147 
148 void G4OpenGLVboDrawer:: vboGlClear(Wt::WFlags< GLenum > mask) {
149  if (fVboViewer->isInitialized()) {
150  fVboViewer->clear(mask);
151  }
152 }
153 
154 
155 void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WMatrix4x4 &m) {
156  if (fVboViewer) {
157  vboGlUseProgram(fVboViewer->getShaderProgram());
158  fVboViewer->uniformMatrix4(location, m);
159  }
160 }
161 
162 
163 void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const double* matrix) {
164  if (fVboViewer) {
165  Wt::WMatrix4x4 mat(
166  (double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
167  (double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
168  (double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
169  (double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
170 
171  fVboViewer->uniformMatrix4(location, mat);
172  }
173 }
174 
175 void G4OpenGLVboDrawer:: vboGlUniformMatrix4fv(const Wt::WGLWidget::UniformLocation &location, const float* matrix) {
176  if (fVboViewer) {
177  Wt::WMatrix4x4 mat(
178  (double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
179  (double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
180  (double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
181  (double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
182 
183  fVboViewer->uniformMatrix4(location, mat);
184  }
185 }
186 
187 void G4OpenGLVboDrawer:: vboGlUniformMatrix4(const Wt::WGLWidget::UniformLocation &location, const Wt::WGLWidget::JavaScriptMatrix4x4 &m) {
188  if (fVboViewer->isInitialized()) {
189  fVboViewer->uniformMatrix4(location, m);
190  }
191 }
192 
193 Wt::WGLWidget::Buffer G4OpenGLVboDrawer:: vboGlCreateBuffer(){
194  if (fVboViewer) {
195  return fVboViewer->createBuffer();
196  }
197  return Wt::WGLWidget::Buffer();
198 }
199 
200 void G4OpenGLVboDrawer:: vboGlBindBuffer(GLenum target, Wt::WGLWidget::Buffer buffer){
201  if (fVboViewer) {
202  fVboViewer->bindBuffer(target,buffer);
203  }
204 }
205 
206 void G4OpenGLVboDrawer:: vboGlDeleteBuffer(Wt::WGLWidget::Buffer buffer){
207  if (fVboViewer == NULL) return;
208  fVboViewer->deleteBuffer(buffer);
209 }
210 
211 void G4OpenGLVboDrawer:: vboGlVertexAttribPointer(Wt::WGLWidget::AttribLocation location, int size, GLenum type, bool normalized, unsigned stride, unsigned offset){
212  if (fVboViewer->isInitialized()) {
213  fVboViewer->vertexAttribPointer(location, size,type, normalized, stride, offset);
214  }
215 }
216 
217 Wt::WGLWidget::Program G4OpenGLVboDrawer:: vboGlCreateProgram(){
218  if (fVboViewer) {
219  return fVboViewer->createProgram();
220  }
221  return Wt::WGLWidget::Program();
222 }
223 
224 void G4OpenGLVboDrawer:: vboGlAttachShader(Wt::WGLWidget::Program program, Shader shader){
225  if (fVboViewer) {
226  fVboViewer->attachShader(program,shader);
227  }
228 }
229 
230 void G4OpenGLVboDrawer:: vboGlLinkProgram(Wt::WGLWidget::Program program){
231  if (fVboViewer) {
232  fVboViewer->linkProgram(program);
233  }
234 }
235 
236 void G4OpenGLVboDrawer:: vboGlUseProgram(Wt::WGLWidget::Program program){
237  if (fVboViewer) {
238  fVboViewer->useProgram(program);
239  }
240 }
241 
242 void G4OpenGLVboDrawer:: vboGlEnableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
243  if (fVboViewer) {
244  fVboViewer->enableVertexAttribArray(pointer);
245  }
246 }
247 
248 void G4OpenGLVboDrawer:: vboGlDisableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
249  if (fVboViewer) {
250  fVboViewer->disableVertexAttribArray(pointer);
251  }
252 }
253 
254 Wt::WGLWidget::UniformLocation G4OpenGLVboDrawer:: vboGlGetUniformLocation(Wt::WGLWidget::Program programm,const std::string &src){
255  if (fVboViewer) {
256  return fVboViewer->getUniformLocation(programm, src);
257  }
258  return Wt::WGLWidget::UniformLocation();
259 }
260 
261 Wt::WGLWidget::AttribLocation G4OpenGLVboDrawer:: vboGlGetAttribLocation(Wt::WGLWidget::Program shader,const std::string &src){
262  if (fVboViewer) {
263  return fVboViewer->getAttribLocation(shader, src);
264  }
265  return Wt::WGLWidget::AttribLocation();
266 }
267 
268 
269 
270 
271 
272 void G4OpenGLVboDrawer::vboGlClearColor (double r, double g, double b, double a) {
273 
274  if (fVboViewer->isInitialized() ) {
275 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
276  fVboViewer->clearColor(r,g,b,a);
277 #else
278 #endif
279  }
280 }
281 
282 void G4OpenGLVboDrawer::vboGlClearDepth(double depth) {
283  if (fVboViewer->isInitialized()) {
284 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
285  fVboViewer->clearDepth(depth);
286 #else
287  glClearDepth(depth);
288 #endif
289  }
290 }
291 
292 
293 void G4OpenGLVboDrawer::vboGlFlush() {
294  if (fVboViewer->isInitialized()) {
295 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
296  fVboViewer->flush();
297 #else
298 #endif
299  }
300 }
301 
302 void G4OpenGLVboDrawer:: vboGlViewport(int x, int y, unsigned width, unsigned height) {
303  if (fVboViewer->isInitialized()) {
304 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
305  fVboViewer->viewport(x,y,width,height);
306 #else
307 #endif
308  }
309 }
310 
311 void G4OpenGLVboDrawer:: vboGlEnable(GLenum cap) {
312  if (fVboViewer->isInitialized()) {
313 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
314  if (cap != Wt::WGLWidget::NONE) {
315  fVboViewer->enable(cap);
316  }
317 #else
318 #endif
319  }
320 }
321 
322 void G4OpenGLVboDrawer:: vboGlDisable(GLenum cap) {
323  if (fVboViewer->isInitialized()) {
324 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
325  if (cap != Wt::WGLWidget::NONE) {
326  fVboViewer->disable(cap);
327  }
328 #else
329 #endif
330  }
331 }
332 
333 void G4OpenGLVboDrawer:: vboGlBlendFunc (GLenum sfactor, GLenum dfactor) {
334  if (fVboViewer->isInitialized()) {
335 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
336  fVboViewer->blendFunc(sfactor, dfactor);
337 #else
338 #endif
339 
340  }
341 }
342 
343 void G4OpenGLVboDrawer:: vboGlDepthFunc (GLenum func) {
344  if (fVboViewer->isInitialized()) {
345 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
346  fVboViewer->depthFunc(func);
347 #else
348 #endif
349  }
350 }
351 
352 void G4OpenGLVboDrawer:: vboGlDepthMask(bool flag) {
353  if (fVboViewer->isInitialized()) {
354 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
355  fVboViewer->depthMask(flag);
356 #else
357 #endif
358  }
359 }
360 
361 void G4OpenGLVboDrawer:: vboGlColorMask (bool red, bool green, bool blue, bool alpha) {
362  if (fVboViewer->isInitialized()) {
363 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
364  fVboViewer->colorMask(red,green,blue,alpha);
365 #else
366 #endif
367  }
368 }
369 
370 void G4OpenGLVboDrawer:: vboGlLineWidth(double width) {
371  if (fVboViewer->isInitialized()) {
372 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
373  fVboViewer->lineWidth(width);
374 #else
375 #endif
376  }
377 }
378 
379 
380 void G4OpenGLVboDrawer:: vboGlDrawArrays(GLenum mode, int first, unsigned count){
381  if (fVboViewer->isInitialized()) {
382 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
383  fVboViewer->drawArrays(mode,first, count);
384 #else
385 #endif
386  }
387 }
388 
389 void G4OpenGLVboDrawer:: vboGlDrawElements(GLenum mode, unsigned count, GLenum type, unsigned offset){
390  if (fVboViewer->isInitialized()) {
391 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
392  fVboViewer->drawElements(mode,count,type,offset);
393 #else
394 #endif
395  }
396 }
397 
398 void G4OpenGLVboDrawer:: vboGlBufferDatafv(GLenum target, const std::vector<double>::iterator begin, const std::vector<double>::iterator end, GLenum usage){
399  if (fVboViewer) {
400  if (fVboViewer->isInitialized()) {
401  fVboViewer->bufferDatafv(target,begin,end,usage);
402  }
403  }
404 }
405 
406 void G4OpenGLVboDrawer:: vboGlBufferDataiv(GLenum target, const std::vector<unsigned short>::iterator begin, const std::vector<unsigned short>::iterator end, GLenum usage, GLenum type){
407  if (fVboViewer) {
408  if (fVboViewer->isInitialized()) {
409  fVboViewer->bufferDataiv(target,begin,end,usage,type);
410  }
411  }
412 }
413 
414 
415 void G4OpenGLVboDrawer:: vboGlMultMatrixd(const GLdouble *matrix){
416  if (fVboViewer) {
417  if (fVboViewer->isInitialized()) {
418  Wt::WMatrix4x4 mat(
419  (double) matrix[0], (double) matrix[4], (double) matrix[8], (double) matrix[12],
420  (double) matrix[1], (double) matrix[5], (double) matrix[9], (double) matrix[13],
421  (double) matrix[2], (double) matrix[6], (double) matrix[10],(double) matrix[14],
422  (double) matrix[3],(double) matrix[7],(double) matrix[11],(double) matrix[15]);
423 
424  // FIXME !
425  fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
426  if (fMatrixMode == GL_MODELVIEW) {
427  // fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
428  } else {
429  G4cerr << "glMultMatrixd could only be used in GL_MODELVIEW mode" << G4endl;
430  }
431  }
432  }
433 }
434 
435 void G4OpenGLVboDrawer:: vboGlMultMatrixf(const GLfloat *matrix){
436  if (fVboViewer) {
437  if (fVboViewer->isInitialized()) {
438  Wt::WMatrix4x4 mat(
439  matrix[0], matrix[4], matrix[8], matrix[12],
440  matrix[1], matrix[5], matrix[9], matrix[13],
441  matrix[2], matrix[6], matrix[10], matrix[14],
442  matrix[3], matrix[7], matrix[11], matrix[15]);
443 
444  if (fMatrixMode == GL_MODELVIEW) {
445  fVboViewer->uniformMatrix4(fVboViewer->getShaderTransformMatrix(),mat);
446  } else {
447  G4cerr << "glMultMatrixf could only be used in GL_MODELVIEW mode" << G4endl;
448  }
449  }
450  }
451 }
452 
453 void G4OpenGLVboDrawer:: vboGlShaderSource(Shader shader, GLsizei , const GLchar **src, const GLint *){
454  if (fVboViewer) {
455  std::string s = *src;
456  fVboViewer->shaderSource(shader, s);
457  }
458 }
459 
460 void G4OpenGLVboDrawer:: vboGlCompileShader(Shader shader){
461  if (fVboViewer) {
462  fVboViewer->compileShader(shader);
463  }
464 }
465 
466 Shader G4OpenGLVboDrawer:: vboGlCreateShader(GLenum shader){
467  if (fVboViewer) {
468  return fVboViewer->createShader(shader);
469  }
470  return Shader();
471 }
472 
473 #else
474 
475 // +--------------------------------+
476 // + QT (OpenGL ES) case +
477 // +--------------------------------+
478 
479 void G4OpenGLVboDrawer:: vboGlMultMatrixf(const GLfloat *matrix){
480  if (fVboViewer) {
481  if (fVboViewer->isInitialized()) {
482  // FIXME
483  // glUniformMatrix4fv(12, 1, 0, 0x7fff5fbf5d00)
484  // Error: GL_INVALID_OPERATION
485 
486  if (fMatrixMode == GL_MODELVIEW) {
487  glUniformMatrix4fv(fVboViewer->getShaderTransformMatrix(),1,0,matrix);
488  } else {
489  G4cerr << "glMultMatrixf could only be used in GL_MODELVIEW mode" << G4endl;
490  }
491  }
492  }
493 }
494 
495 
496 void G4OpenGLVboDrawer:: vboGlMultMatrixd(const GLdouble *matrix){
497  if (fVboViewer) {
498  if (fVboViewer->isInitialized()) {
499  // FIXME !
500  // if (fMatrixMode == GL_MODELVIEW) {
501  // printf("G4OpenGLVboDrawer:: vboGlMultMatrixd %d %d\n",fVboViewer->getShaderTransformMatrix(), matrix);
503  float mat[16] = {
504  matrix[0],matrix[1],matrix[2],matrix[3],
505  matrix[4],matrix[5],matrix[6],matrix[7],
506  matrix[8],matrix[9],matrix[10],matrix[11],
507  matrix[12],matrix[13],matrix[14],matrix[15]
508  };
509 
510  glUniformMatrix4fv(fVboViewer->getShaderTransformMatrix(),1,0,mat);
511  GLenum e = glGetError();
512  printf("GL error : %d",e);
513  // } else {
514  // G4cerr << "glMultMatrixd could only be used in GL_MODELVIEW mode" << G4endl;
515  // }
516  }
517  }
518 }
519 
520 
521 
522 #endif
523 // +--------------------------------+
524 // + All case +
525 // +--------------------------------+
526 
527 
528 
529 void G4OpenGLVboDrawer::vboGlOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) {
530  if (fVboViewer) {
531  if (fVboViewer->isInitialized()) {
532  printf("glOrtho implemented --- %f %f %f %f %f %f \n",left, right, bottom, top, zNear, zFar);
533  float a = 2.0f / (right - left);
534  float b = 2.0f / (top - bottom);
535  float c = -2.0f / (zFar - zNear);
536 
537  float tx = - (right + left)/(right - left);
538  float ty = - (top + bottom)/(top - bottom);
539  float tz = - (zFar + zNear)/(zFar - zNear);
540 
541  float ortho[16] = {
542  a, 0, 0, 0,
543  0, b, 0, 0,
544  0, 0, c, 0,
545  tx, ty, tz, 1
546  };
547  // FIXME :
548  // glUniformMatrix4fv(0, 1, 0, 0x7fff5fbf5d00)
549  // Error: GL_INVALID_OPERATION
550 
551  if (fMatrixMode == GL_PROJECTION) {
552 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
553  vboGlUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), ortho);
554 #else
555  glUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), 1, 0, ortho);
556 #endif
557  } else {
558  G4cerr << "glFrustum could only be used in GL_PROJECTION mode" << G4endl;
559  }
560  }
561  }
562 }
563 
564 
565 void G4OpenGLVboDrawer::vboGlFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) {
566  if (fVboViewer) {
567  if (fVboViewer->isInitialized()) {
568  float deltaX = right - left;
569  float deltaY = top - bottom;
570  float deltaZ = zFar - zNear;
571 
572  float a = 2.0f * zNear / deltaX;
573  float b = 2.0f * zNear / deltaY;
574  float c = (right + left) / deltaX;
575  float d = (top + bottom) / deltaY;
576  float e = -(zFar + zNear) / (zFar - zNear);
577  float f = -2.0f * zFar * zNear / deltaZ;
578 
579  float proj[16] = {
580  a, 0, 0, 0,
581  0, b, 0, 0,
582  c, d, e, -1.0f,
583  0, 0, f, 0
584  };
585 
586  if (fMatrixMode == GL_PROJECTION) {
587 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
588  vboGlUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), proj);
589 #else
590  glUniformMatrix4fv(fVboViewer->getShaderProjectionMatrix(), 1, 0, proj);
591 #endif
592  } else {
593  G4cerr << "glFrustrum could only be used in GL_PROJECTION mode" << G4endl;
594  }
595  }
596  }
597 }
598 
599 
600 void G4OpenGLVboDrawer::vboGlMatrixMode(GLenum a) {
601  if (fVboViewer) {
602  if (fVboViewer->isInitialized()) {
603  printf("G4OpenGLVboDrawer::vboGlMatrixMode CHANGED :%d \n",a);
604  fMatrixMode = a;
605  }
606  }
607 }
608 
609 
610 void G4OpenGLVboDrawer::vboGlColor4d(int red,int green,int blue,int alpha) {
611  if (fVboViewer) {
612  if (fVboViewer->isInitialized()) {
613  // double color [] = { red, green, blue, alpha };
614  // FIXME : REMOVE /2 , used to render transparents for testing purpose
615 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
616  double color [] = { red, green, blue, 0.7 };
617  glUniform4fv (fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color);
618 #else
619  alpha = 0.7;
620  glUniform4f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),red, green, blue, alpha);
621 #endif
622  }
623  }
624 }
625 
626 void G4OpenGLVboDrawer:: vboGlColor4fv(const GLfloat* data) {
627  if (fVboViewer) {
628  if (fVboViewer->isInitialized()) {
629  double color [] = { (data[0]), (data[1]), (data[2]), 0.7};
630  // FIXME : REMOVE /2 , used to render transparents for testing purpose
631 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
632  glUniform4fv (fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color);
633 #else
634  glUniform4f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointColor"),color[0],color[1],color[2], color[3]);
635 #endif
636  }
637  }
638 }
639 
640 void G4OpenGLVboDrawer:: vboGlPointSize(float size) {
641  if (fVboViewer) {
642  if (fVboViewer->isInitialized()) {
643 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
644  glUniform1f(fVboViewer->getUniformLocation(fVboViewer->getShaderProgram(), "uPointSize"),size);
645 #else
646  glUniform1f (glGetUniformLocation(fVboViewer->getShaderProgram(), "uPointSize"),size);
647 #endif
648  }
649  }
650 }
651 
652 #endif
653 
const XML_Char * target
Definition: expat.h:268
static ush mask[]
Definition: csz_inflate.cc:317
#define buffer
Definition: xmlparse.cc:628
static constexpr double g
Definition: G4SIunits.hh:183
const XML_Char const XML_Char * data
Definition: expat.h:268
const XML_Char * s
Definition: expat.h:262
static constexpr double m
Definition: G4SIunits.hh:129
#define G4endl
Definition: G4ios.hh:61
static const G4double alpha
G4GLOB_DLL std::ostream G4cerr