33 #ifndef G4OpenGLVboDrawer_HH
34 #define G4OpenGLVboDrawer_HH
38 #ifdef G4OPENGL_VERSION_2
41 #define GL2PS_TEXT_B 4
42 #define GL2PS_TEXT_BL 5
43 #define GL2PS_TEXT_BR 6
50 #define glEdgeFlag(a) fVboDrawer->empty()
51 #define glRenderMode(a) fVboDrawer->returnNULL()
52 #define glClipPlane(a,b) fVboDrawer->empty()
53 #define glGetIntegerv(a,b) fVboDrawer->empty()
54 #define glGetFloatv(a,b) fVboDrawer->empty()
55 #define glGetDoublev(a,b) fVboDrawer->empty()
56 #define glPassThrough fVboDrawer->empty()
57 #define glGetBooleanv fVboDrawer->empty()
58 #define glLoadName(a) fVboDrawer->empty()
59 #define glPushMatrix() fVboDrawer->empty()
60 #define glLoadIdentity() fVboDrawer->empty()
61 #define glPopMatrix() fVboDrawer->empty()
62 #define glCallList(a) fVboDrawer->empty()
63 #define glGenLists(a) fVboDrawer->returnNULL()
64 #define glVertex3d fVboDrawer->empty()
65 #define glBegin fVboDrawer->empty()
66 #define glEnd fVboDrawer->empty()
67 #define glNewList(a,b) fVboDrawer->empty()
68 #define glEndList() fVboDrawer->empty()
69 #define glPolygonMode(a,b) fVboDrawer->empty()
70 #define glDrawBuffer(a) fVboDrawer->empty()
71 #define glDeleteLists(a,b) fVboDrawer->empty()
72 #define glStencilFunc(a,b,c) fVboDrawer->empty()
73 #define glStencilOp(a,b,c) fVboDrawer->empty()
74 #define glColorMaterial(a,b) fVboDrawer->empty()
75 #define glLightfv(a,b,c) fVboDrawer->empty()
76 #define glScaled(a,b,c) fVboDrawer->empty()
77 #define gluLookAt fVboDrawer->empty()
78 #define gluPickMatrix fVboDrawer->empty()
79 #define glSelectBuffer(a,b) fVboDrawer->empty()
80 #define glInitNames() fVboDrawer->empty()
81 #define glPushNames(a) fVboDrawer->empty()
82 #define glPushName(a) fVboDrawer->empty()
83 #define glPixelStorei(a,b) fVboDrawer->empty()
84 #define glRasterPos3d(a,b,c) fVboDrawer->empty()
85 #define Geant4_gl2psTextOpt(a,b,c,d,e) fVboDrawer->empty()
86 #define glMaterialfv(a,b,c) fVboDrawer->empty()
87 #define glCullFace(a) fVboDrawer->empty()
88 #define glReadBuffer(a) fVboDrawer->empty()
89 #define glReadPixels(a,b,c,d,e,f,g) fVboDrawer->empty()
90 #define glTranslatef(a,b,c) fVboDrawer->empty() // TO BE FIXED
96 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
98 class G4OpenGLImmediateWtViewer;
103 #define glGetError() Wt::WGLWidget::NONE
105 #define glOrtho fVboDrawer->vboGlOrtho
106 #define glFrustum fVboDrawer->vboGlFrustum
107 #define glViewport fVboDrawer->vboGlViewport
108 #define glEnable fVboDrawer->vboGlEnable
109 #define glDisable fVboDrawer->vboGlDisable
110 #define glBlendFunc fVboDrawer->vboGlBlendFunc
111 #define glClear fVboDrawer->vboGlClear
112 #define glClearColor fVboDrawer->vboGlClearColor
113 #define glClearDepth fVboDrawer->vboGlClearDepth
114 #define glDepthFunc fVboDrawer->vboGlDepthFunc
115 #define glDepthMask fVboDrawer->vboGlDepthMask
116 #define glFlush fVboDrawer->vboGlFlush
117 #define glColorMask fVboDrawer->vboGlColorMask
118 #define glLineWidth fVboDrawer->vboGlLineWidth
119 #define glUniformMatrix4 fVboDrawer->vboGlUniformMatrix4
120 #define glDrawArrays fVboDrawer->vboGlDrawArrays
121 #define glCreateBuffer fVboDrawer->vboGlCreateBuffer
122 #define glVertexPointer fVboDrawer->vboGlVertexPointer
123 #define glBindBuffer fVboDrawer->vboGlBindBuffer
124 #define glDeleteBuffer fVboDrawer->vboGlDeleteBuffer
125 #define glBufferDatafv fVboDrawer->vboGlBufferDatafv
126 #define glBufferDataiv fVboDrawer->vboGlBufferDataiv
127 #define glGetAttribLocation fVboDrawer->vboGlGetAttribLocation
128 #define glEnableVertexAttribArray fVboDrawer->vboGlEnableVertexAttribArray
129 #define glDisableVertexAttribArray fVboDrawer->vboGlDisableVertexAttribArray
130 #define glShaderSource fVboDrawer->vboGlShaderSource
131 #define glCompileShader fVboDrawer->vboGlCompileShader
132 #define glCreateShader fVboDrawer->vboGlCreateShader
133 #define glCreateProgram fVboDrawer->vboGlCreateProgram
134 #define glAttachShader fVboDrawer->vboGlAttachShader
135 #define glLinkProgram fVboDrawer->vboGlLinkProgram
136 #define glUseProgram fVboDrawer->vboGlUseProgram
137 #define glDrawElements fVboDrawer->vboGlDrawElements
138 #define glVertexAttribPointer fVboDrawer->vboGlVertexAttribPointer
139 #define glGetUniformLocation fVboDrawer->vboGlGetUniformLocation
140 #define glPointSize fVboDrawer->vboGlPointSize
141 #define glColor3d fVboDrawer->vboGlColor3d
142 #define glColor4d fVboDrawer->vboGlColor4d
143 #define glColor4fv fVboDrawer->vboGlColor4fv
144 #define glMultMatrixd fVboDrawer->vboGlMultMatrixd
145 #define glMultMatrixf fVboDrawer->vboGlMultMatrixf
146 #define glGetUniformLocation fVboDrawer->vboGlGetUniformLocation
147 #define glGetAttribLocation fVboDrawer->vboGlGetAttribLocation
148 #define glMatrixMode fVboDrawer->vboGlMatrixMode
152 #define glUniform1f fVboViewer->uniform1f
153 #define glUniform4fv fVboViewer->uniform4fv
154 #define glUniformMatrix4dv fVboDrawer->vboGlUniformMatrix4;
155 #define glUniformMatrix4fv fVboDrawer->vboGlUniformMatrix4fv;
159 #define GL_VIEWPORT Wt::WGLWidget::VIEWPORT
160 #define GL_RGBA Wt::WGLWidget::RGBA
161 #define GL_ONE_MINUS_SRC_ALPHA Wt::WGLWidget::ONE_MINUS_SRC_ALPHA
162 #define GL_BLEND Wt::WGLWidget::BLEND
163 #define GL_SRC_ALPHA Wt::WGLWidget::SRC_ALPHA
164 #define GL_LEQUAL Wt::WGLWidget::LEQUAL
165 #define GL_FALSE false
166 #define GL_LESS Wt::WGLWidget::LESS
167 #define GL_SELECT Wt::WGLWidget::SELECT
169 #define GL_RGB Wt::WGLWidget::RGB
170 #define GL_CURRENT_RASTER_POSITION_VALID Wt::WGLWidget::CURRENT_RASTER_POSITION_VALID
171 #define GL_ONE Wt::WGLWidget::ONE
172 #define GL_ZERO Wt::WGLWidget::ZERO
173 #define GL_COLOR_INDEX Wt::WGLWidget::COLOR_INDEX
174 #define GL_LINE_TOKEN Wt::WGLWidget::LINE_TOKEN
175 #define GL_LINE_RESET_TOKEN Wt::WGLWidget::LINE_RESET_TOKEN
176 #define GL_POLYGON_TOKEN Wt::WGLWidget::POLYGON_TOKEN
177 #define GL_FEEDBACK Wt::WGLWidget::FEEDBACK
178 #define GL_COLOR_CLEAR_VALUE Wt::WGLWidget::COLOR_CLEAR_VALUE
179 #define GL_BITMAP_TOKEN Wt::WGLWidget::BITMAP_TOKEN
180 #define GL_DRAW_PIXEL_TOKEN Wt::WGLWidget::DRAW_PIXEL_TOKEN
181 #define GL_COPY_PIXEL_TOKEN Wt::WGLWidget::COPY_PIXEL_TOKEN
182 #define GL_PASS_THROUGH_TOKEN Wt::WGLWidget::PASS_THROUGH_TOKEN
183 #define GL_3D_COLOR Wt::WGLWidget::3D_COLOR
184 #define GL_DEPTH_TEST Wt::WGLWidget::DEPTH_TEST
185 #define GL_FRONT Wt::WGLWidget::FRONT
186 #define GL_BACK Wt::WGLWidget::BACK
187 #define GL_FRONT_AND_BACK Wt::WGLWidget::FRONT_AND_BACK
188 #define GL_OUT_OF_MEMORY Wt::WGLWidget::OUT_OF_MEMORY
189 #define GL_LINE_STRIP Wt::WGLWidget::LINE_STRIP
190 #define GL_QUADS Wt::WGLWidget::QUADS
191 #define GL_LINE_LOOP Wt::WGLWidget::LINE_LOOP
192 #define GL_LINES Wt::WGLWidget::LINES
193 #define GL_POINTS Wt::WGLWidget::POINTS
194 #define GL_TRIANGLES Wt::WGLWidget::TRIANGLES
195 #define GL_TRIANGLE_STRIP Wt::WGLWidget::TRIANGLE_STRIP
196 #define GL_TRIANGLE_FAN Wt::WGLWidget::TRIANGLE_FAN
197 #define GL_FLOAT Wt::WGLWidget::FLOAT
198 #define GL_STENCIL_TEST Wt::WGLWidget::STENCIL_TEST
199 #define GL_ALWAYS Wt::WGLWidget::ALWAYS
200 #define GL_INVERT Wt::WGLWidget::INVERT
201 #define GL_COMPILE_AND_EXECUTE Wt::WGLWidget::COMPILE_AND_EXECUTE
202 #define GL_COMPILE Wt::WGLWidget::COMPILE
203 #define GL_COLOR_BUFFER_BIT Wt::WGLWidget::COLOR_BUFFER_BIT
204 #define GL_DEPTH_BUFFER_BIT Wt::WGLWidget::DEPTH_BUFFER_BIT
205 #define GL_STENCIL_BUFFER_BIT Wt::WGLWidget::STENCIL_BUFFER_BIT
206 #define GL_UNSIGNED_BYTE Wt::WGLWidget::UNSIGNED_BYTE
207 #define GL_ARRAY_BUFFER Wt::WGLWidget::ARRAY_BUFFER
208 #define GL_ELEMENT_ARRAY_BUFFER Wt::WGLWidget::ELEMENT_ARRAY_BUFFER
209 #define GL_RENDER Wt::WGLWidget::RENDER
210 #define GL_LUMINANCE Wt::WGLWidget::LUMINANCE
211 #define GL_STATIC_DRAW Wt::WGLWidget::STATIC_DRAW
212 #define GL_FRAGMENT_SHADER Wt::WGLWidget::FRAGMENT_SHADER
213 #define GL_VERTEX_SHADER Wt::WGLWidget::VERTEX_SHADER
214 #define GL_UNSIGNED_INT Wt::WGLWidget::UNSIGNED_INT
215 #define GL_UNSIGNED_SHORT Wt::WGLWidget::UNSIGNED_SHORT
216 #define GL_CULL_FACE Wt::WGLWidget::CULL_FACE
217 #define GL_MAX_VIEWPORT_DIMS Wt::WGLWidget::MAX_VIEWPORT_DIMS
218 #define GL_PROJECTION Wt::WGLWidget::FRAGMENT_SHADER // Not the good value, but should be ok, work together with GL_MODELVIEW
219 #define GL_MODELVIEW Wt::WGLWidget::VERTEX_SHADER // Not the good value, but should be ok, work together with GL_PROJECTION
224 #define GL_PROJECTION_MATRIX 0
225 #define GL_UNPACK_SWAP_BYTES 0
226 #define GL_UNPACK_LSB_FIRST 0
227 #define GL_UNPACK_SKIP_ROWS 0
228 #define GL_UNPACK_LOW_LENGHT 0
229 #define GL_UNPACK_SKIP_PIXELS 0
230 #define GL_UNPACK_ALIGNMENT 0
231 #define GL_UNPACK_ROW_LENGTH 0
232 #define GL_CLIP_PLANE0 Wt::WGLWidget::NONE
233 #define GL_CLIP_PLANE1 Wt::WGLWidget::NONE
234 #define GL_CLIP_PLANE2 Wt::WGLWidget::NONE
235 #define GL_CLIP_PLANE3 Wt::WGLWidget::NONE
236 #define GL_CLIP_PLANE4 Wt::WGLWidget::NONE
237 #define GL_COLOR_MATERIAL Wt::WGLWidget::NONE
238 #define GL_AMBIENT_AND_DIFFUSE Wt::WGLWidget::NONE
240 #define GL_LIGHTING Wt::WGLWidget::NONE
241 #define GL_POINT_SMOOTH Wt::WGLWidget::NONE
242 #define GL_LINE_SMOOTH Wt::WGLWidget::NONE
243 #define GL_POLYGON_SMOOTH Wt::WGLWidget::NONE
244 #define GL_LIGHT0 Wt::WGLWidget::NONE
245 #define GL_AMBIENT Wt::WGLWidget::NONE
246 #define GL_DIFFUSE Wt::WGLWidget::NONE
247 #define GL_POSITION Wt::WGLWidget::NONE
249 #define GLenum Wt::WGLWidget::GLenum
251 typedef unsigned char GLboolean;
252 typedef unsigned int GLbitfield;
255 typedef short GLshort;
257 typedef unsigned char GLubyte;
258 typedef unsigned short GLushort;
259 typedef unsigned int GLuint;
261 typedef float GLfloat;
262 typedef float GLclampf;
263 typedef double GLdouble;
264 typedef double GLclampd;
273 class G4OpenGLImmediateQtViewer;
275 #define glOrtho fVboDrawer->vboGlOrtho
276 #define glFrustum fVboDrawer->vboGlFrustum
277 #define glMultMatrixf fVboDrawer->vboGlMultMatrixf
278 #define glMultMatrixd fVboDrawer->vboGlMultMatrixd
279 #define glMatrixMode fVboDrawer->vboGlMatrixMode
280 #define glPointSize fVboDrawer->vboGlPointSize
281 #define glColor3d fVboDrawer->vboGlColor3d
282 #define glColor4d fVboDrawer->vboGlColor4d
283 #define glColor4fv fVboDrawer->vboGlColor4fv
286 #endif // G4VIS_BUILD_OPENGLQT_DRIVER
289 class G4OpenGLViewer;
291 class G4OpenGLVboDrawer {
293 G4OpenGLVboDrawer (G4OpenGLViewer*, std::string type);
297 virtual ~G4OpenGLVboDrawer ();
300 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
301 void vboGlClear(Wt::WFlags< GLenum >
mask);
302 void vboGlUniformMatrix4(
const Wt::WGLWidget::UniformLocation &location,
const Wt::WMatrix4x4 &mat);
303 void vboGlUniformMatrix4(
const Wt::WGLWidget::UniformLocation &location,
const double* matrix);
304 void vboGlUniformMatrix4fv(
const Wt::WGLWidget::UniformLocation &location,
const float* matrix);
305 void vboGlUniformMatrix4(
const Wt::WGLWidget::UniformLocation &location,
const Wt::WGLWidget::JavaScriptMatrix4x4 &mat);
306 Wt::WGLWidget::Buffer vboGlCreateBuffer();
307 void vboGlBindBuffer(GLenum
target, Wt::WGLWidget::Buffer
buffer);
308 void vboGlDeleteBuffer(Wt::WGLWidget::Buffer
buffer);
309 void vboGlVertexAttribPointer(Wt::WGLWidget::AttribLocation location,
int size, GLenum type,
bool normalized,
unsigned stride,
unsigned offset);
310 void vboGlShaderSource(Wt::WGLWidget::Shader shader, GLsizei ,
const GLchar **src,
const GLint *);
311 void vboGlCompileShader(Wt::WGLWidget::Shader shader);
312 Wt::WGLWidget::Shader vboGlCreateShader(GLenum shader);
313 Wt::WGLWidget::Program vboGlCreateProgram();
314 void vboGlAttachShader(Wt::WGLWidget::Program program, Wt::WGLWidget::Shader shader);
315 void vboGlLinkProgram(Wt::WGLWidget::Program program);
316 void vboGlUseProgram(Wt::WGLWidget::Program program);
317 void vboGlEnableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer);
318 void vboGlDisableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer);
319 Wt::WGLWidget::UniformLocation vboGlGetUniformLocation(Wt::WGLWidget::Program programm,
const std::string &src);
320 Wt::WGLWidget::AttribLocation vboGlGetAttribLocation(Wt::WGLWidget::Program shader,
const std::string &src);
322 void vboGlClearColor (
double r,
double g,
double b,
double a);
323 void vboGlClearDepth(
double depth);
324 void vboGlViewport(
int x,
int y,
unsigned width,
unsigned height);
325 void vboGlEnable(GLenum cap);
326 void vboGlDisable(GLenum cap);
327 void vboGlBlendFunc (GLenum sfactor, GLenum dfactor);
328 void vboGlDepthFunc (GLenum func);
329 void vboGlDepthMask(
bool flag);
330 void vboGlColorMask (
bool red,
bool green,
bool blue,
bool alpha);
331 void vboGlLineWidth(
double width);
332 void vboGlDrawArrays(GLenum mode,
int first,
unsigned count);
333 void vboGlBufferDatafv(GLenum
target,
const std::vector<double>::iterator begin,
const std::vector<double>::iterator end, GLenum
usage);
334 void vboGlBufferDataiv(GLenum
target,
const std::vector<unsigned short>::iterator begin,
const std::vector<unsigned short>::iterator end, GLenum
usage, GLenum type);
335 void vboGlDrawElements(GLenum mode,
unsigned count, GLenum type,
unsigned offset);
336 void vboGlMultMatrixf(
const GLfloat *
m );
337 void vboGlMultMatrixd(
const GLdouble *
m );
339 void vboGlMultMatrixf(
const GLfloat *
m );
340 void vboGlMultMatrixd(
const GLdouble *
m );
344 void vboGlOrtho(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
345 void vboGlFrustum(GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
346 void vboGlMatrixMode(GLenum);
347 void vboGlPointSize(
float size);
348 inline void vboGlColor3d(
int red,
int green,
int blue) {
349 vboGlColor4d(red,green, blue, 1.0);
351 void vboGlColor4d(
int red,
int green,
int blue,
int alpha);
352 void vboGlColor4fv(
const GLfloat*);
353 inline const char * getFragmentShaderSrc() {
354 return fFragmentShaderSrc;
356 inline const char * getVertexShaderSrc() {
357 return fVertexShaderSrc;
359 inline bool isVBO() {
360 if ((fOGLType ==
"OGL-ES") || (fOGLType ==
"OGL-VBO")) {
365 inline void empty() {}
366 inline GLuint returnNULL() {
371 const char *fFragmentShaderSrc;
372 const char *fVertexShaderSrc;
373 std::string fOGLType;
376 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
377 G4OpenGLImmediateWtViewer* fVboViewer;
379 G4OpenGLImmediateQtViewer* fVboViewer;
380 #endif // G4VIS_BUILD_OPENGLWT_DRIVER
383 #endif // G4OPENGL_VERSION_2
385 #endif // G4OpenGLVboDrawer_HH
std::vector< ExP01TrackerHit * > a
static constexpr double m
static const G4double alpha