35 #ifdef G4VIS_BUILD_OPENGLWT_DRIVER
41 G4OpenGLWtDrawer::G4OpenGLWtDrawer (G4OpenGLViewer* viewer
47 G4OpenGLImmediateWtViewer*
v =
dynamic_cast<G4OpenGLImmediateWtViewer*
>(viewer);
54 G4OpenGLWtDrawer::~G4OpenGLWtDrawer (
61 void G4OpenGLWtDrawer::wglClearColor (
double r,
double g,
double b,
double a) {
64 fWtViewer->clearColor(r,g,b,a);
68 void G4OpenGLWtDrawer::wglClearDepth(
double depth) {
70 fWtViewer->clearDepth(depth);
74 void G4OpenGLWtDrawer::wglClear(Wt::WFlags< GLenum > mask) {
76 fWtViewer->clear(mask);
80 void G4OpenGLWtDrawer::wglFlush() {
86 void G4OpenGLWtDrawer::wglViewport(
int x,
int y,
unsigned width,
unsigned height) {
88 fWtViewer->viewport(x,y,width,height);
92 void G4OpenGLWtDrawer::wglEnable(GLenum cap) {
94 fWtViewer->enable(cap);
98 void G4OpenGLWtDrawer::wglDisable(GLenum cap) {
100 fWtViewer->disable(cap);
104 void G4OpenGLWtDrawer::wglBlendFunc (GLenum sfactor, GLenum dfactor) {
106 fWtViewer->blendFunc(sfactor, dfactor);
110 void G4OpenGLWtDrawer::wglDepthFunc (GLenum func) {
112 fWtViewer->depthFunc(func);
116 void G4OpenGLWtDrawer::wglDepthMask(
bool flag) {
118 fWtViewer->depthMask(flag);
122 void G4OpenGLWtDrawer::wglColorMask (
bool red,
bool green,
bool blue,
bool alpha) {
124 fWtViewer->colorMask(red,green,blue,alpha);
128 void G4OpenGLWtDrawer::wglLineWidth(
double width) {
130 fWtViewer->lineWidth(width);
134 void G4OpenGLWtDrawer::wglUniformMatrix4(
const Wt::WGLWidget::UniformLocation &location,
const Wt::WMatrix4x4 &
m) {
136 fWtViewer->uniformMatrix4(location, m);
140 void G4OpenGLWtDrawer::wglUniformMatrix4(
const Wt::WGLWidget::UniformLocation &location,
const Wt::WGLWidget::JavaScriptMatrix4x4 &m) {
142 fWtViewer->uniformMatrix4(location, m);
146 void G4OpenGLWtDrawer::wglDrawArrays(GLenum mode,
int first,
unsigned count){
148 fWtViewer->drawArrays(mode,first, count);
152 void G4OpenGLWtDrawer::wglDrawElements(GLenum mode,
unsigned count, GLenum type,
unsigned offset){
154 fWtViewer->drawElements(mode,count,type,offset);
158 Wt::WGLWidget::Buffer G4OpenGLWtDrawer::wglCreateBuffer(){
160 return fWtViewer->createBuffer();
165 void G4OpenGLWtDrawer::wglBindBuffer(GLenum
target, Wt::WGLWidget::Buffer
buffer){
167 fWtViewer->bindBuffer(target,buffer);
171 void G4OpenGLWtDrawer::wglDeleteBuffer(Wt::WGLWidget::Buffer buffer){
172 if (fWtViewer == NULL)
return;
173 fWtViewer->deleteBuffer(buffer);
176 void G4OpenGLWtDrawer::wglBufferDatafv(GLenum target,
const std::vector<double>::iterator begin,
const std::vector<double>::iterator end, GLenum
usage){
178 fWtViewer->bufferDatafv(target,begin,end,usage);
182 void G4OpenGLWtDrawer::wglBufferDataiv(GLenum target,
const std::vector<unsigned short>::iterator begin,
const std::vector<unsigned short>::iterator end, GLenum usage){
184 fWtViewer->bufferDataiv(target,begin,end,usage, GL_UNSIGNED_SHORT);
188 void G4OpenGLWtDrawer::wglVertexAttribPointer(Wt::WGLWidget::AttribLocation location,
int size, GLenum type,
bool normalized,
unsigned stride,
unsigned offset){
190 fWtViewer->vertexAttribPointer(location, size,type, normalized, stride, offset);
194 void G4OpenGLWtDrawer::wglMultMatrixd(
const GLdouble *matrix){
197 (
double) matrix[0], (
double) matrix[4], (
double) matrix[8], (
double) matrix[12],
198 (
double) matrix[1], (
double) matrix[5], (
double) matrix[9], (
double) matrix[13],
199 (
double) matrix[2], (
double) matrix[6], (
double) matrix[10],(
double) matrix[14],
200 (
double) matrix[3],(
double) matrix[7],(
double) matrix[11],(
double) matrix[15]);
202 fWtViewer->uniformMatrix4(fWtViewer->getUniformLocation(fWtViewer->shaderProgram_,
"uTMatrix"),
mat);
206 void G4OpenGLWtDrawer::wglPointSize(
float size) {
208 fWtViewer->uniform1f (fWtViewer->getUniformLocation(fWtViewer->shaderProgram_,
"uPointSize"),size);
212 void G4OpenGLWtDrawer::wglColor4d(
int red,
int green,
int blue,
int alpha) {
215 double color [] = {
red, green,
blue, 0.7 };
217 fWtViewer->uniform4fv (fWtViewer->getUniformLocation(fWtViewer->shaderProgram_,
"uPointColor"),color);
221 void G4OpenGLWtDrawer::wglColor4fv(
const GLfloat*
data) {
224 double color [] = { (data[0]), (data[1]), (data[2]), 0.7};
226 fWtViewer->uniform4fv (fWtViewer->getUniformLocation(fWtViewer->shaderProgram_,
"uPointColor"),color);
230 void G4OpenGLWtDrawer::wglShaderSource(Shader shader, GLsizei ,
const GLchar **src,
const GLint *){
232 std::string
s = *src;
233 fWtViewer->shaderSource(shader, s);
237 void G4OpenGLWtDrawer::wglCompileShader(Shader shader){
239 fWtViewer->compileShader(shader);
243 Shader G4OpenGLWtDrawer::wglCreateShader(GLenum shader){
245 return fWtViewer->createShader(shader);
250 Wt::WGLWidget::Program G4OpenGLWtDrawer::wglCreateProgram(){
252 return fWtViewer->createProgram();
257 void G4OpenGLWtDrawer::wglAttachShader(Wt::WGLWidget::Program program, Shader shader){
259 fWtViewer->attachShader(program,shader);
263 void G4OpenGLWtDrawer::wglLinkProgram(Wt::WGLWidget::Program program){
265 fWtViewer->linkProgram(program);
269 void G4OpenGLWtDrawer::wglUseProgram(Wt::WGLWidget::Program program){
271 fWtViewer->useProgram(program);
275 void G4OpenGLWtDrawer::wglEnableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
277 fWtViewer->enableVertexAttribArray(pointer);
281 void G4OpenGLWtDrawer::wglDisableVertexAttribArray(Wt::WGLWidget::AttribLocation pointer){
283 fWtViewer->disableVertexAttribArray(pointer);
287 Wt::WGLWidget::UniformLocation G4OpenGLWtDrawer::wglGetUniformLocation(Wt::WGLWidget::Program programm,
const std::string &src){
289 return fWtViewer->getUniformLocation(programm, src);
294 Wt::WGLWidget::AttribLocation G4OpenGLWtDrawer::wglGetAttribLocation(Shader shader,
const std::string &src){
296 return fWtViewer->getAttribLocation(shader, src);
const XML_Char const XML_Char * data