35 #ifdef G4VIS_BUILD_OPENGL_DRIVER
64 #ifdef G4OPENGL_VERSION_2
65 fEmulate_GL_QUADS(false),
70 fEventsDrawInterval(1),
71 fEventsWaitingToBeFlushed(0),
72 fThreePassCapable(false),
73 fSecondPassForTransparencyRequested(false),
74 fSecondPassForTransparency(false),
75 fThirdPassForNonHiddenMarkersRequested(false),
76 fThirdPassForNonHiddenMarkers(false),
81 G4OpenGLSceneHandler::~G4OpenGLSceneHandler ()
86 const GLubyte G4OpenGLSceneHandler::fStippleMaskHashed [128] = {
87 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
88 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
89 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
90 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
91 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
92 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
93 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
94 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
95 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
96 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
97 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
98 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
99 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
100 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
101 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,
102 0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55
105 void G4OpenGLSceneHandler::ClearAndDestroyAtts()
107 std::map<GLuint, G4AttHolder*>::iterator i;
108 for (i = fPickMap.begin(); i != fPickMap.end(); ++i)
delete i->second;
112 void G4OpenGLSceneHandler::ScaledFlush()
114 fEventsWaitingToBeFlushed++;
115 if (fEventsWaitingToBeFlushed < fEventsDrawInterval)
return;
117 fEventsWaitingToBeFlushed = 0;
120 void G4OpenGLSceneHandler::ProcessScene()
122 fThreePassCapable =
true;
127 if (fSecondPassForTransparencyRequested) {
128 fSecondPassForTransparency =
true;
130 fSecondPassForTransparency =
false;
131 fSecondPassForTransparencyRequested =
false;
135 if (fThirdPassForNonHiddenMarkersRequested) {
136 fThirdPassForNonHiddenMarkers =
true;
138 fThirdPassForNonHiddenMarkers =
false;
139 fThirdPassForNonHiddenMarkersRequested =
false;
142 fThreePassCapable =
false;
145 void G4OpenGLSceneHandler::PreAddSolid
152 void G4OpenGLSceneHandler::BeginPrimitives
158 void G4OpenGLSceneHandler::EndPrimitives ()
163 void G4OpenGLSceneHandler::BeginPrimitives2D
169 void G4OpenGLSceneHandler::EndPrimitives2D ()
174 G4VSolid* G4OpenGLSceneHandler::CreateSectionSolid ()
185 G4VSolid* G4OpenGLSceneHandler::CreateCutawaySolid ()
194 void G4OpenGLSceneHandler::AddPrimitive (
const G4Polyline& line)
196 G4int nPoints = line.size ();
197 if (nPoints <= 0)
return;
201 #ifndef G4OPENGL_VERSION_2
202 glDisable (GL_LIGHTING);
209 G4double lineWidth = GetLineWidth(pVA);
214 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
215 if (pGLViewer) pGLViewer->ChangeLineWidth(lineWidth);
218 #ifndef G4OPENGL_VERSION_2
219 glBegin (GL_LINE_STRIP);
224 for (
G4int iPoint = 0; iPoint < nPoints; iPoint++) {
226 x = line[iPoint].x();
227 y = line[iPoint].y();
228 z = line[iPoint].z();
229 glVertex3d (x, y, z);
233 glBeginVBO(GL_LINE_STRIP);
235 for (
G4int iPoint = 0; iPoint < nPoints; iPoint++) {
236 fOglVertex.push_back(line[iPoint].
x());
237 fOglVertex.push_back(line[iPoint].y());
238 fOglVertex.push_back(line[iPoint].
z());
240 fOglVertex.push_back(0);
241 fOglVertex.push_back(0);
242 fOglVertex.push_back(1);
249 void G4OpenGLSceneHandler::AddPrimitive (
const G4Polymarker& polymarker)
251 if (polymarker.size() == 0) {
257 #ifndef G4OPENGL_VERSION_2
258 glDisable (GL_LIGHTING);
265 MarkerSizeType sizeType;
266 G4double size = GetMarkerSize(polymarker, sizeType);
272 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
273 if (!pGLViewer)
return;
275 if (sizeType == world) {
276 G4double lineWidth = GetLineWidth(pVA);
277 pGLViewer->ChangeLineWidth(lineWidth);
282 static G4bool hashedWarned =
false;
286 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
287 glEdgeFlag (GL_TRUE);
292 G4cout <<
"Hashed fill style in G4OpenGLSceneHandler."
293 <<
"\n Not implemented. Using G4VMarker::filled."
301 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
308 if (sizeType == world) {
318 nSides = GetNoOfSides(pVA);
328 fpViewer -> GetViewParameters().GetViewpointDirection();
329 const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector();
332 G4Vector3D start = radius * (up.cross(viewpointDirection)).unit();
335 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
337 #ifndef G4OPENGL_VERSION_2
338 glBegin (GL_POLYGON);
339 for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
340 G4Vector3D r = start; r.rotate(phi, viewpointDirection);
342 glVertex3d (p.x(), p.y(), p.z());
346 glBeginVBO (GL_TRIANGLE_STRIP);
347 for (i = 0, phi = startPhi; i < nSides; i++, phi += dPhi) {
348 G4Vector3D r = start; r.rotate(phi, viewpointDirection);
351 fOglVertex.push_back(p.x());
352 fOglVertex.push_back(p.y());
353 fOglVertex.push_back(p.z());
355 fOglVertex.push_back(0);
356 fOglVertex.push_back(0);
357 fOglVertex.push_back(1);
365 pGLViewer->ChangePointSize(size);
368 #ifndef G4OPENGL_VERSION_2
373 glEnable (GL_POINT_SMOOTH);
break;
375 glDisable (GL_POINT_SMOOTH);
break;
378 #ifndef G4OPENGL_VERSION_2
380 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
382 glVertex3d(centre.x(),centre.y(),centre.z());
386 glBeginVBO(GL_POINTS);
388 for (
size_t iPoint = 0; iPoint < polymarker.size (); iPoint++) {
389 fOglVertex.push_back(polymarker[iPoint].
x());
390 fOglVertex.push_back(polymarker[iPoint].y());
391 fOglVertex.push_back(polymarker[iPoint].
z());
392 fOglVertex.push_back(0);
393 fOglVertex.push_back(0);
394 fOglVertex.push_back(1);
401 void G4OpenGLSceneHandler::AddPrimitive (
const G4Text& text) {
404 #ifdef G4OPENGL_VERSION_2
407 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
408 if (pGLViewer) pGLViewer->DrawText(text);
411 void G4OpenGLSceneHandler::AddPrimitive (
const G4Circle& circle) {
416 G4OpenGLSceneHandler::AddPrimitive(oneCircle);
419 void G4OpenGLSceneHandler::AddPrimitive (
const G4Square& square) {
424 G4OpenGLSceneHandler::AddPrimitive(oneSquare);
427 void G4OpenGLSceneHandler::AddPrimitive (
const G4Scale& scale)
433 void G4OpenGLSceneHandler::AddPrimitive (
const G4Polyhedron& polyhedron) {
438 if (polyhedron.GetNoFacets() == 0)
return;
442 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
443 if (!pGLViewer)
return;
457 GLfloat* painting_colour;
458 GLfloat current_colour [4];
459 glGetFloatv (GL_CURRENT_COLOR, current_colour);
461 G4bool isTransparent =
false;
462 if (current_colour[3] < 1.) {
463 isTransparent =
true;
469 GLfloat clear_colour[4];
470 glGetFloatv (GL_COLOR_CLEAR_VALUE, clear_colour);
471 painting_colour = clear_colour;
473 painting_colour = current_colour;
476 G4double lineWidth = GetLineWidth(pVA);
477 pGLViewer->ChangeLineWidth(lineWidth);
479 G4bool isAuxEdgeVisible = GetAuxEdgeVisible (pVA);
481 G4bool clipping = pGLViewer->fVP.IsSection() || pGLViewer->fVP.IsCutaway();
484 #ifndef G4OPENGL_VERSION_2
485 glDisable (GL_LIGHTING);
488 switch (drawing_style) {
492 glEnable (GL_STENCIL_TEST);
495 glStencilFunc (GL_ALWAYS, 0, 1);
496 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
497 glEnable (GL_DEPTH_TEST);
498 glDepthFunc (GL_LEQUAL);
501 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
502 glEnable(GL_COLOR_MATERIAL);
503 glDisable (GL_CULL_FACE);
504 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
508 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
509 glEnable(GL_COLOR_MATERIAL);
510 glDisable (GL_CULL_FACE);
511 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
513 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
514 glEnable(GL_COLOR_MATERIAL);
515 glEnable (GL_CULL_FACE);
516 glCullFace (GL_BACK);
517 glPolygonMode (GL_FRONT, GL_LINE);
522 glEnable (GL_DEPTH_TEST);
523 glDepthFunc (GL_LEQUAL);
526 glDepthMask (GL_FALSE);
527 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
528 #ifndef G4OPENGL_VERSION_2
529 glEnable(GL_COLOR_MATERIAL);
531 glDisable (GL_CULL_FACE);
532 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
535 glDepthMask (GL_TRUE);
537 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
538 glEnable(GL_COLOR_MATERIAL);
539 glDisable (GL_CULL_FACE);
540 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
542 glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
543 #ifndef G4OPENGL_VERSION_2
544 glEnable(GL_COLOR_MATERIAL);
546 glEnable (GL_CULL_FACE);
547 glCullFace (GL_BACK);
548 glPolygonMode (GL_FRONT, GL_FILL);
551 #ifndef G4OPENGL_VERSION_2
552 if (!fProcessing2D) glEnable (GL_LIGHTING);
557 glEnable (GL_DEPTH_TEST);
558 glDepthFunc (GL_LEQUAL);
559 glDisable (GL_CULL_FACE);
560 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
566 #ifndef G4OPENGL_VERSION_2
568 glEdgeFlag (GL_TRUE);
570 fEmulate_GL_QUADS =
true;
571 glBeginVBO(GL_TRIANGLE_STRIP);
581 notLastFace = polyhedron.GetNextFacet(nEdges, vertex, edgeFlag, normals);
584 for(
G4int edgeCount = 0; edgeCount < nEdges; ++edgeCount) {
586 if (isAuxEdgeVisible) {
587 edgeFlag[edgeCount] = 1;
589 #ifndef G4OPENGL_VERSION_2
590 if (edgeFlag[edgeCount] > 0) {
591 if (fEdgeFlag !=
true) {
592 glEdgeFlag (GL_TRUE);
596 if (fEdgeFlag !=
false) {
597 glEdgeFlag (GL_FALSE);
601 glNormal3d (normals[edgeCount].
x(),
602 normals[edgeCount].y(),
603 normals[edgeCount].
z());
604 glVertex3d (vertex[edgeCount].
x(),
605 vertex[edgeCount].y(),
606 vertex[edgeCount].
z());
609 fOglVertex.push_back(vertex[edgeCount].
x());
610 fOglVertex.push_back(vertex[edgeCount].y());
611 fOglVertex.push_back(vertex[edgeCount].
z());
613 fOglVertex.push_back(normals[edgeCount].
x());
614 fOglVertex.push_back(normals[edgeCount].y());
615 fOglVertex.push_back(normals[edgeCount].
z());
625 normals[edgeCount] = normals[0];
626 vertex[edgeCount] = vertex[0];
627 #ifndef G4OPENGL_VERSION_2
628 edgeFlag[edgeCount] = -1;
629 if (fEdgeFlag !=
false) {
630 glEdgeFlag (GL_FALSE);
634 glNormal3d (normals[edgeCount].
x(),
635 normals[edgeCount].y(),
636 normals[edgeCount].
z());
637 glVertex3d (vertex[edgeCount].
x(),
638 vertex[edgeCount].y(),
639 vertex[edgeCount].
z());
641 fOglVertex.push_back(vertex[edgeCount].
x());
642 fOglVertex.push_back(vertex[edgeCount].y());
643 fOglVertex.push_back(vertex[edgeCount].
z());
645 fOglVertex.push_back(normals[edgeCount].
x());
646 fOglVertex.push_back(normals[edgeCount].y());
647 fOglVertex.push_back(normals[edgeCount].
z());
654 "G4OpenGLSceneHandler::AddPrimitive(G4Polyhedron): WARNING"
655 "\n G4Polyhedron facet with " << nEdges <<
" edges" <<
G4endl;
663 #ifndef G4OPENGL_VERSION_2
664 glDisable(GL_COLOR_MATERIAL);
667 #ifndef G4OPENGL_VERSION_2
677 glDisable (GL_LIGHTING);
680 glStencilFunc (GL_EQUAL, 0, 1);
681 glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
683 if (!fProcessing2D) glEnable (GL_LIGHTING);
685 glEnable (GL_DEPTH_TEST);
686 glDepthFunc (GL_LEQUAL);
689 glDepthMask (GL_FALSE);
690 glDisable (GL_CULL_FACE);
691 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
694 glDepthMask (GL_TRUE);
696 glDisable (GL_CULL_FACE);
697 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
699 glEnable (GL_CULL_FACE);
700 glCullFace (GL_BACK);
701 glPolygonMode (GL_FRONT, GL_FILL);
707 goto end_of_drawing_through_stencil;
712 glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, painting_colour);
715 glMaterialfv (GL_FRONT, GL_AMBIENT_AND_DIFFUSE, painting_colour);
717 glColor4fv (painting_colour);
718 #ifndef G4OPENGL_VERSION_2
720 glEdgeFlag (GL_TRUE);
723 fEmulate_GL_QUADS =
true;
724 glBeginVBO(GL_TRIANGLE_STRIP);
727 for (
int edgeCount = 0; edgeCount < 4; ++edgeCount) {
728 #ifndef G4OPENGL_VERSION_2
729 if (edgeFlag[edgeCount] > 0) {
730 if (fEdgeFlag !=
true) {
731 glEdgeFlag (GL_TRUE);
735 if (fEdgeFlag !=
false) {
736 glEdgeFlag (GL_FALSE);
740 glNormal3d (normals[edgeCount].
x(),
741 normals[edgeCount].y(),
742 normals[edgeCount].
z());
743 glVertex3d (vertex[edgeCount].
x(),
744 vertex[edgeCount].y(),
745 vertex[edgeCount].
z());
747 fOglVertex.push_back(vertex[edgeCount].
x());
748 fOglVertex.push_back(vertex[edgeCount].y());
749 fOglVertex.push_back(vertex[edgeCount].
z());
751 fOglVertex.push_back(normals[edgeCount].
x());
752 fOglVertex.push_back(normals[edgeCount].y());
753 fOglVertex.push_back(normals[edgeCount].
z());
757 #ifndef G4OPENGL_VERSION_2
762 end_of_drawing_through_stencil:
765 glStencilFunc (GL_ALWAYS, 0, 1);
766 glStencilOp (GL_INVERT, GL_INVERT, GL_INVERT);
767 glDepthFunc (GL_LEQUAL);
770 glDisable (GL_CULL_FACE);
771 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
775 glDisable (GL_CULL_FACE);
776 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
778 glEnable (GL_CULL_FACE);
779 glCullFace (GL_BACK);
780 glPolygonMode (GL_FRONT, GL_LINE);
783 glDisable (GL_LIGHTING);
784 glColor4fv (current_colour);
786 #ifndef G4OPENGL_VERSION_2
788 glEdgeFlag (GL_TRUE);
791 fEmulate_GL_QUADS =
true;
792 glBeginVBO(GL_TRIANGLE_STRIP);
794 for (
int edgeCount = 0; edgeCount < 4; ++edgeCount) {
795 #ifndef G4OPENGL_VERSION_2
796 if (edgeFlag[edgeCount] > 0) {
797 if (fEdgeFlag !=
true) {
798 glEdgeFlag (GL_TRUE);
802 if (fEdgeFlag !=
false) {
803 glEdgeFlag (GL_FALSE);
807 glNormal3d (normals[edgeCount].
x(),
808 normals[edgeCount].y(),
809 normals[edgeCount].
z());
810 glVertex3d (vertex[edgeCount].
x(),
811 vertex[edgeCount].y(),
812 vertex[edgeCount].
z());
814 fOglVertex.push_back(vertex[edgeCount].
x());
815 fOglVertex.push_back(vertex[edgeCount].y());
816 fOglVertex.push_back(vertex[edgeCount].
z());
818 fOglVertex.push_back(normals[edgeCount].
x());
819 fOglVertex.push_back(normals[edgeCount].y());
820 fOglVertex.push_back(normals[edgeCount].
z());
824 #ifndef G4OPENGL_VERSION_2
830 glDepthFunc (GL_LEQUAL);
832 #ifndef G4OPENGL_VERSION_2
834 glEdgeFlag (GL_TRUE);
840 fEmulate_GL_QUADS =
true;
841 glBeginVBO(GL_TRIANGLE_STRIP);
844 }
while (notLastFace);
846 #ifndef G4OPENGL_VERSION_2
854 GLenum oldDrawArrayType = fDrawArrayType;
856 if (dynamic_cast<const G4PolyhedronTrd2*>(&polyhedron)) {
858 }
else if (dynamic_cast<const G4PolyhedronCons*>(&polyhedron)) {
863 fDrawArrayType = oldDrawArrayType;
866 glDisable (GL_STENCIL_TEST);
867 glDepthMask (GL_TRUE);
868 #ifndef G4OPENGL_VERSION_2
869 glDisable (GL_LIGHTING);
873 void G4OpenGLSceneHandler::AddCompound(
const G4VTrajectory& traj) {
877 void G4OpenGLSceneHandler::AddCompound(
const G4VHit& hit) {
881 void G4OpenGLSceneHandler::AddCompound(
const G4VDigi& digi) {
890 #ifdef G4OPENGL_VERSION_2
893 void G4OpenGLSceneHandler::OptimizeVBOForTrd(){
898 std::vector<double> vertices;
899 vertices.insert (vertices.end(),fOglVertex.begin(),fOglVertex.begin()+6*6);
900 vertices.insert (vertices.end(),fOglVertex.begin()+9*6,fOglVertex.begin()+9*6+6);
901 vertices.insert (vertices.end(),fOglVertex.begin()+13*6,fOglVertex.begin()+13*6+6);
902 fOglVertex = vertices;
905 3,2,0,1,4,5,7,6, 6,0,4,3,7,2,6,1,5
907 fOglIndices.insert(fOglIndices.begin(), myarray, myarray+17);
909 fDrawArrayType = GL_TRIANGLE_STRIP;
913 void G4OpenGLSceneHandler::OptimizeVBOForCons(
G4int aNoFaces){
937 std::vector<double> vertices;
941 vertices.insert (vertices.end(),fOglVertex.begin()+ (aNoFaces*4)*6,fOglVertex.begin()+(aNoFaces*4)*6+6);
942 vertices.insert (vertices.end(),fOglVertex.begin()+ (aNoFaces*8+1)*6,fOglVertex.begin()+(aNoFaces*8+1)*6+6);
946 for (
G4int a = 0;
a<aNoFaces;
a++) {
947 posInVertice =
a*4*6;
948 vertices.insert (vertices.end(),fOglVertex.begin()+posInVertice,fOglVertex.begin()+posInVertice+1*6+6);
950 vertices.insert (vertices.end(),fOglVertex.begin(),fOglVertex.begin()+1*6*6);
951 fOglVertex = vertices;
957 fOglIndices.push_back(0);
958 fOglIndices.push_back(
a*2+2);
961 fOglIndices.push_back(0);
962 fOglIndices.push_back(2);
965 for (
G4int a = 0;
a<aNoFaces;
a++) {
966 fOglIndices.push_back(
a*2+2);
967 fOglIndices.push_back(
a*2+1+2);
969 fOglIndices.push_back(2);
970 fOglIndices.push_back(2+1);
975 fOglIndices.push_back(
a*2+3);
976 fOglIndices.push_back(1);
979 fOglIndices.push_back(0+3);
981 fDrawArrayType = GL_TRIANGLE_STRIP;
982 fEmulate_GL_QUADS =
false;
985 void G4OpenGLSceneHandler::glBeginVBO(GLenum type) {
986 fDrawArrayType = type;
987 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
988 glGenBuffers(1,&fVertexBufferObject);
989 glGenBuffers(1,&fIndicesBufferObject);
991 fVertexBufferObject = glCreateBuffer();
992 fIndicesBufferObject = glCreateBuffer();
1006 void G4OpenGLSceneHandler::glEndVBO() {
1007 if (fOglIndices.size() == 0) {
1010 std::vector<double> vertices;
1012 if (fEmulate_GL_QUADS ==
true) {
1013 fEmulate_GL_QUADS =
false;
1030 for (
unsigned int a=0;
a<fOglVertex.size();
a+=6*4) {
1031 vertices.insert (vertices.end(),fOglVertex.begin()+
a,fOglVertex.begin()+
a+1*6+6);
1034 if (
a+4*6+5 < fOglVertex.size()) {
1035 if ((fOglVertex[
a+2*6+0] != fOglVertex[
a+5*6+0]) ||
1036 (fOglVertex[
a+2*6+1] != fOglVertex[
a+5*6+1]) ||
1037 (fOglVertex[
a+2*6+2] != fOglVertex[
a+5*6+2]) ||
1038 (fOglVertex[
a+2*6+3] != fOglVertex[
a+5*6+3]) ||
1039 (fOglVertex[
a+2*6+4] != fOglVertex[
a+5*6+4]) ||
1040 (fOglVertex[
a+2*6+5] != fOglVertex[
a+5*6+5]) ||
1042 (fOglVertex[
a+3*6+0] != fOglVertex[
a+4*6+0]) ||
1043 (fOglVertex[
a+3*6+1] != fOglVertex[
a+4*6+1]) ||
1044 (fOglVertex[
a+3*6+2] != fOglVertex[
a+4*6+2]) ||
1045 (fOglVertex[
a+3*6+3] != fOglVertex[
a+4*6+3]) ||
1046 (fOglVertex[
a+3*6+4] != fOglVertex[
a+4*6+4]) ||
1047 (fOglVertex[
a+3*6+5] != fOglVertex[
a+4*6+5])) {
1049 vertices.insert (vertices.end(),fOglVertex.begin()+
a+3*6,fOglVertex.begin()+
a+3*6+6);
1050 vertices.insert (vertices.end(),fOglVertex.begin()+
a+2*6,fOglVertex.begin()+
a+2*6+6);
1052 drawVBOArray(vertices);
1056 vertices.insert (vertices.end(),fOglVertex.begin()+
a+3*6,fOglVertex.begin()+
a+3*6+6);
1057 vertices.insert (vertices.end(),fOglVertex.begin()+
a+2*6,fOglVertex.begin()+
a+2*6+6);
1060 fOglVertex = vertices;
1063 drawVBOArray(fOglVertex);
1068 glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
1071 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1072 int sizeV = fOglVertex.size();
1075 glBufferData(GL_ARRAY_BUFFER,
sizeof(
double)*sizeV, &fOglVertex[0], GL_STATIC_DRAW);
1077 glBufferDatafv(GL_ARRAY_BUFFER, fOglVertex.begin(), fOglVertex.end(), GL_STATIC_DRAW);
1081 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fIndicesBufferObject);
1084 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1085 int sizeI = fOglIndices.size();
1086 glBufferData(GL_ELEMENT_ARRAY_BUFFER,
sizeof(
int)*sizeI, &fOglIndices[0], GL_STATIC_DRAW);
1088 glBufferDataiv(GL_ELEMENT_ARRAY_BUFFER, fOglIndices.begin(), fOglIndices.end(), GL_STATIC_DRAW, GL_UNSIGNED_BYTE);
1094 glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
1095 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fIndicesBufferObject);
1098 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
1100 glEnableVertexAttribArray(pGLViewer->fVertexPositionAttribute);
1102 glVertexAttribPointer(pGLViewer->fVertexPositionAttribute,
1114 glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
1115 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, fIndicesBufferObject);
1117 glDrawElements(fDrawArrayType, fOglIndices.size(), GL_UNSIGNED_SHORT, 0);
1120 glDisableVertexAttribArray(pGLViewer->fVertexPositionAttribute);
1124 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1125 glDeleteBuffers(1,&fVertexBufferObject);
1127 glDeleteBuffer(fVertexBufferObject);
1132 void G4OpenGLSceneHandler::drawVBOArray(std::vector<double> vertices) {
1133 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1134 glGenBuffers(1,&fVertexBufferObject);
1135 glGenBuffers(1,&fIndicesBufferObject);
1137 fVertexBufferObject = glCreateBuffer();
1138 fIndicesBufferObject = glCreateBuffer();
1142 glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
1144 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1145 int s = vertices.size();
1146 glBufferData(GL_ARRAY_BUFFER,
sizeof(
double)*s, &vertices[0], GL_STATIC_DRAW);
1148 glBufferDatafv(GL_ARRAY_BUFFER, vertices.begin(), vertices.end(), GL_STATIC_DRAW);
1154 glBindBuffer(GL_ARRAY_BUFFER, fVertexBufferObject);
1157 G4OpenGLViewer* pGLViewer =
dynamic_cast<G4OpenGLViewer*
>(fpViewer);
1159 glEnableVertexAttribArray(pGLViewer->fVertexPositionAttribute);
1169 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1170 glVertexAttribPointer(pGLViewer->fVertexPositionAttribute,
1180 glVertexAttribPointer(pGLViewer->fVertexPositionAttribute,
1192 glDrawArrays(fDrawArrayType,
1193 0, vertices.size()/6);
1195 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1196 glDisableClientState( GL_VERTEX_ARRAY );
1198 glDisableVertexAttribArray(pGLViewer->fVertexPositionAttribute);
1203 #ifndef G4VIS_BUILD_OPENGLWT_DRIVER
1204 glDeleteBuffers(1,&fVertexBufferObject);
1206 glDeleteBuffer(fVertexBufferObject);
virtual G4VSolid * CreateSectionSolid()
MarkerType GetMarkerType() const
virtual void BeginPrimitives(const G4Transform3D &objectTransformation)
HepGeom::Point3D< G4double > G4Point3D
HepGeom::Vector3D< G4double > G4Vector3D
G4Point3D GetPosition() const
const G4VisAttributes * GetVisAttributes() const
virtual void AddPrimitive(const G4Polyline &)=0
virtual G4VSolid * CreateCutawaySolid()
G4GLOB_DLL std::ostream G4cout
static const double twopi
virtual void EndPrimitives()
virtual void BeginPrimitives2D(const G4Transform3D &objectTransformation)
virtual void AddCompound(const G4VTrajectory &)
virtual void ProcessScene()
const G4double x[NPOINTSGL]
virtual void PreAddSolid(const G4Transform3D &objectTransformation, const G4VisAttributes &)
FillStyle GetFillStyle() const
virtual void EndPrimitives2D()
G4GLOB_DLL std::ostream G4cerr
HepGeom::Normal3D< G4double > G4Normal3D