Bug Summary

File:scratch/gluex/scan-build-work/hdgeant4/src/G4fixes/G4OpenGLStoredSceneHandler.cc
Location:line 293, column 9
Description:Called C++ object pointer is null

Annotated Source Code

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: G4OpenGLStoredSceneHandler.cc 108544 2018-02-16 09:47:30Z gcosmo $
28//
29//
30// Andrew Walkden 10th February 1997
31// OpenGL stored scene - creates OpenGL display lists.
32
33#ifdef G4VIS_BUILD_OPENGL_DRIVER1
34
35#include "G4OpenGLStoredSceneHandler.hh"
36
37#include "G4PhysicalVolumeModel.hh"
38#include "G4LogicalVolumeModel.hh"
39#include "G4VPhysicalVolume.hh"
40#include "G4LogicalVolume.hh"
41#include "G4Polyline.hh"
42#include "G4Polymarker.hh"
43#include "G4Text.hh"
44#include "G4Circle.hh"
45#include "G4Square.hh"
46#include "G4Polyhedron.hh"
47#include "G4AttHolder.hh"
48#include "G4OpenGLTransform3D.hh"
49#include "G4OpenGLViewer.hh"
50#include "G4AttHolder.hh"
51
52#include <typeinfo>
53
54G4int G4OpenGLStoredSceneHandler::fSceneIdCount = 0;
55
56G4int G4OpenGLStoredSceneHandler::fDisplayListId = 0;
57G4bool G4OpenGLStoredSceneHandler::fMemoryForDisplayLists = true;
58G4int G4OpenGLStoredSceneHandler::fDisplayListLimit = 50000;
59
60G4OpenGLStoredSceneHandler::PO::PO():
61 fDisplayListId(0),
62 fPickName(0),
63 fpG4TextPlus(0),
64 fMarkerOrPolyline(false)
65{}
66
67G4OpenGLStoredSceneHandler::PO::PO(const G4OpenGLStoredSceneHandler::PO& po):
68 fDisplayListId(po.fDisplayListId),
69 fTransform(po.fTransform),
70 fPickName(po.fPickName),
71 fColour(po.fColour),
72 fpG4TextPlus(po.fpG4TextPlus? new G4TextPlus(*po.fpG4TextPlus): 0),
73 fMarkerOrPolyline(po.fMarkerOrPolyline)
74{}
75
76G4OpenGLStoredSceneHandler::PO::PO(G4int id, const G4Transform3D& tr):
77 fDisplayListId(id),
78 fTransform(tr),
79 fPickName(0),
80 fpG4TextPlus(0),
81 fMarkerOrPolyline(false)
82{}
83
84G4OpenGLStoredSceneHandler::PO::~PO()
85{
86 delete fpG4TextPlus;
87}
88
89G4OpenGLStoredSceneHandler::PO& G4OpenGLStoredSceneHandler::PO::operator=
90 (const G4OpenGLStoredSceneHandler::PO& rhs)
91{
92 if (&rhs == this) return *this;
93 fDisplayListId = rhs.fDisplayListId;
94 fTransform = rhs.fTransform;
95 fPickName = rhs.fPickName;
96 fColour = rhs.fColour;
97 fpG4TextPlus = rhs.fpG4TextPlus? new G4TextPlus(*rhs.fpG4TextPlus): 0;
98 fMarkerOrPolyline = rhs.fMarkerOrPolyline;
99 return *this;
100}
101
102G4OpenGLStoredSceneHandler::TO::TO():
103 fDisplayListId(0),
104 fPickName(0),
105 fStartTime(-DBL_MAXstd::numeric_limits<double>::max()),
106 fEndTime(DBL_MAXstd::numeric_limits<double>::max()),
107 fpG4TextPlus(0),
108 fMarkerOrPolyline(false)
109{}
110
111G4OpenGLStoredSceneHandler::TO::TO(const G4OpenGLStoredSceneHandler::TO& to):
112 fDisplayListId(to.fDisplayListId),
113 fTransform(to.fTransform),
114 fPickName(to.fPickName),
115 fStartTime(to.fStartTime),
116 fEndTime(to.fEndTime),
117 fColour(to.fColour),
118 fpG4TextPlus(to.fpG4TextPlus? new G4TextPlus(*to.fpG4TextPlus): 0),
119 fMarkerOrPolyline(to.fMarkerOrPolyline)
120{}
121
122G4OpenGLStoredSceneHandler::TO::TO(G4int id, const G4Transform3D& tr):
123 fDisplayListId(id),
124 fTransform(tr),
125 fPickName(0),
126 fStartTime(-DBL_MAXstd::numeric_limits<double>::max()),
127 fEndTime(DBL_MAXstd::numeric_limits<double>::max()),
128 fpG4TextPlus(0),
129 fMarkerOrPolyline(false)
130{}
131
132G4OpenGLStoredSceneHandler::TO::~TO()
133{
134 delete fpG4TextPlus;
135}
136
137G4OpenGLStoredSceneHandler::TO& G4OpenGLStoredSceneHandler::TO::operator=
138 (const G4OpenGLStoredSceneHandler::TO& rhs)
139{
140 if (&rhs == this) return *this;
141 fDisplayListId = rhs.fDisplayListId;
142 fTransform = rhs.fTransform;
143 fPickName = rhs.fPickName;
144 fStartTime = rhs.fStartTime;
145 fEndTime = rhs.fEndTime;
146 fColour = rhs.fColour;
147 fpG4TextPlus = rhs.fpG4TextPlus? new G4TextPlus(*rhs.fpG4TextPlus): 0;
148 fMarkerOrPolyline = rhs.fMarkerOrPolyline;
149 return *this;
150}
151
152G4OpenGLStoredSceneHandler::G4OpenGLStoredSceneHandler
153(G4VGraphicsSystem& system,
154 const G4String& name):
155G4OpenGLSceneHandler (system, fSceneIdCount++, name),
156fTopPODL (0)
157{}
158
159G4OpenGLStoredSceneHandler::~G4OpenGLStoredSceneHandler ()
160{}
161
162void G4OpenGLStoredSceneHandler::BeginPrimitives
163(const G4Transform3D& objectTransformation)
164{
165 G4OpenGLSceneHandler::BeginPrimitives (objectTransformation);
166 if (fReadyForTransients) glDrawBuffer (GL_FRONT0x0404);
167 // Display list setup moved to AddPrimitivePreamble. See notes there.
168}
169
170void G4OpenGLStoredSceneHandler::EndPrimitives ()
171{
172 // See all primitives immediately... At least soon...
173 ScaledFlush();
174 glDrawBuffer (GL_BACK0x0405);
175 G4OpenGLSceneHandler::EndPrimitives ();
176}
177
178void G4OpenGLStoredSceneHandler::BeginPrimitives2D
179(const G4Transform3D& objectTransformation)
180{
181 G4OpenGLSceneHandler::BeginPrimitives2D(objectTransformation);
182 if (fReadyForTransients) glDrawBuffer (GL_FRONT0x0404);
183}
184
185void G4OpenGLStoredSceneHandler::EndPrimitives2D ()
186{
187 // See all primitives immediately... At least soon...
188 ScaledFlush();
189 glDrawBuffer (GL_BACK0x0405);
190 G4OpenGLSceneHandler::EndPrimitives2D ();
191}
192
193G4bool G4OpenGLStoredSceneHandler::AddPrimitivePreamble(const G4VMarker& visible)
194{
195 return AddPrimitivePreambleInternal(visible, true, false);
196}
197G4bool G4OpenGLStoredSceneHandler::AddPrimitivePreamble(const G4Polyline& visible)
198{
199 return AddPrimitivePreambleInternal(visible, false, true);
200}
201G4bool G4OpenGLStoredSceneHandler::AddPrimitivePreamble(const G4Polyhedron& visible)
202{
203 return AddPrimitivePreambleInternal(visible, false, false);
204}
205
206G4bool G4OpenGLStoredSceneHandler::AddPrimitivePreambleInternal(const G4Visible& visible, bool isMarker, bool isPolyline)
207{
208// Get applicable vis attributes for all primitives.
209 fpVisAttribs = fpViewer->GetApplicableVisAttributes(visible.GetVisAttributes());
210 const G4Colour& c = GetColour ();
211 G4double opacity = c.GetAlpha ();
212
213 G4bool transparency_enabled = true;
214 G4bool isMarkerNotHidden = true;
215 G4OpenGLViewer* pViewer = dynamic_cast<G4OpenGLViewer*>(fpViewer);
1
'pViewer' initialized here
216 if (pViewer) {
2
Assuming 'pViewer' is null
3
Taking false branch
217 transparency_enabled = pViewer->transparency_enabled;
218 isMarkerNotHidden = pViewer->fVP.IsMarkerNotHidden();
219 }
220
221 G4bool isTransparent = opacity < 1.;
222 G4bool isMarkerOrPolyline = isMarker || isPolyline;
223 G4bool treatAsTransparent = transparency_enabled && isTransparent;
224 G4bool treatAsNotHidden = isMarkerNotHidden && isMarkerOrPolyline;
225
226 if (fProcessing2D) glDisable (GL_DEPTH_TEST0x0B71);
4
Taking false branch
227 else {
228 if (isMarkerOrPolyline && isMarkerNotHidden)
229 glDisable (GL_DEPTH_TEST0x0B71);
230 else {glEnable (GL_DEPTH_TEST0x0B71); glDepthFunc (GL_LEQUAL0x0203);}
231 }
232
233 if (fThreePassCapable) {
5
Taking false branch
234
235 // Ensure transparent objects are drawn opaque ones and before
236 // non-hidden markers. The problem of blending/transparency/alpha
237 // is quite a tricky one - see History of opengl-V07-01-01/2/3.
238 if (!(fSecondPassForTransparency || fThirdPassForNonHiddenMarkers)) {
239 // First pass...
240 if (treatAsTransparent) { // Request pass for transparent objects...
241 fSecondPassForTransparencyRequested = true;
242 }
243 if (treatAsNotHidden) { // Request pass for non-hidden markers...
244 fThirdPassForNonHiddenMarkersRequested = true;
245 }
246 // On first pass, transparent objects and non-hidden markers are not drawn...
247 if (treatAsTransparent || treatAsNotHidden) {
248 return false; // No further processing.
249 }
250 }
251
252 // On second pass, only transparent objects are drawn...
253 if (fSecondPassForTransparency) {
254 if (!treatAsTransparent) {
255 return false; // No further processing.
256 }
257 }
258
259 // On third pass, only non-hidden markers are drawn...
260 if (fThirdPassForNonHiddenMarkers) {
261 if (!treatAsNotHidden) {
262 return false; // No further processing.
263
264 }
265 }
266 } // fThreePassCapable
267
268 // Loads G4Atts for picking...
269 G4bool isPicking = false;
270 if (fpViewer->GetViewParameters().IsPicking()) {
6
Taking false branch
271 isPicking = true;
272 glLoadName(++fPickName);
273 G4AttHolder* holder = new G4AttHolder;
274 LoadAtts(visible, holder);
275 fPickMap[fPickName] = holder;
276 }
277
278 // Can we re-use a display list?
279 const G4VSolid* pSolid = 0;
280 G4PhysicalVolumeModel* pPVModel =
281 dynamic_cast<G4PhysicalVolumeModel*>(fpModel);
282 if (fpViewer->GetViewParameters().GetVisAttributesModifiers().size())
7
Taking false branch
283 // Touchables have been modified - don't risk re-using display list.
284 goto end_of_display_list_reuse_test;
285 if (pPVModel) {
8
Assuming 'pPVModel' is non-null
9
Taking true branch
286 // Check that it isn't a G4LogicalVolumeModel (which is a sub-class of
287 // G4PhysicalVolumeModel).
288 G4LogicalVolumeModel* pLVModel =
289 dynamic_cast<G4LogicalVolumeModel*>(pPVModel);
290 if (pLVModel)
10
Assuming 'pLVModel' is null
11
Taking false branch
291 // Logical volume model - don't re-use.
292 goto end_of_display_list_reuse_test;
293 if (pViewer->fVP.IsSection() || pViewer->fVP.IsCutaway())
12
Called C++ object pointer is null
294 // sections and cutaways generate unique views of each model instance
295 goto end_of_display_list_reuse_test;
296 // If part of the geometry hierarchy, i.e., from a
297 // G4PhysicalVolumeModel, check if a display list already exists for
298 // this solid, re-use it if possible. We could be smarter, and
299 // recognise repeated branches of the geometry hierarchy, for
300 // example. But this algorithm should be secure, I think...
301 G4VPhysicalVolume* pPV = pPVModel->GetCurrentPV();
302 if (!pPV)
303 // It's probably a dummy model, e.g., for a user-drawn hit?
304 goto end_of_display_list_reuse_test;
305 G4LogicalVolume* pLV = pPV->GetLogicalVolume();
306 if (!pLV)
307 // Dummy model again?
308 goto end_of_display_list_reuse_test;
309 pSolid = pLV->GetSolid();
310 EAxis axis = kRho;
311 G4VPhysicalVolume* pCurrentPV = pPVModel->GetCurrentPV();
312 if (pCurrentPV -> IsReplicated ()) {
313 G4int nReplicas;
314 G4double width;
315 G4double offset;
316 G4bool consuming;
317 pCurrentPV->GetReplicationData(axis,nReplicas,width,offset,consuming);
318 }
319 // Provided it is not parametrised (because if so, the
320 // solid's parameters might have been changed)...
321 if (!(pCurrentPV -> IsParameterised ()) &&
322 // Provided it is not replicated radially (because if so, the
323 // solid's parameters will have been changed)...
324 !(pCurrentPV -> IsReplicated () && axis == kRho) &&
325 // ...and if the solid has already been rendered...
326 (fSolidMap.find (pSolid) != fSolidMap.end ())) {
327 fDisplayListId = fSolidMap [pSolid];
328 PO po(fDisplayListId,fObjectTransformation);
329 if (isPicking) po.fPickName = fPickName;
330 po.fColour = c;
331 po.fMarkerOrPolyline = isMarkerOrPolyline;
332 fPOList.push_back(po);
333 // No need to test if gl commands are used (result of
334 // ExtraPOProcessing) because we have already decided they will
335 // not, at least not here. Also, pass a dummy G4Visible since
336 // not relevant for G4PhysicalVolumeModel.
337 (void) ExtraPOProcessing(G4Visible(), fPOList.size() - 1);
338 return false; // No further processing.
339 }
340 }
341end_of_display_list_reuse_test:
342
343 // Because of our need to control colour of transients (display by
344 // time fading), display lists may only cover a single primitive.
345 // So display list setup is here.
346
347 if (fMemoryForDisplayLists) {
348 fDisplayListId = glGenLists (1);
349 if (glGetError() == GL_OUT_OF_MEMORY0x0505 ||
350 fDisplayListId > fDisplayListLimit) {
351 G4cout(*G4cout_p) <<
352 "********************* WARNING! ********************"
353 "\n* Display list limit reached in OpenGL."
354 "\n* Continuing drawing WITHOUT STORING. Scene only partially refreshable."
355 "\n* Current limit: " << fDisplayListLimit <<
356 ". Change with \"/vis/ogl/set/displayListLimit\"."
357 "\n***************************************************"
358 << G4endlstd::endl;
359 fMemoryForDisplayLists = false;
360 }
361 }
362
363 if (pSolid) fSolidMap [pSolid] = fDisplayListId;
364
365 if (fMemoryForDisplayLists) {
366 if (fReadyForTransients) {
367 TO to(fDisplayListId, fObjectTransformation);
368 if (isPicking) to.fPickName = fPickName;
369 to.fColour = c;
370 to.fStartTime = fpVisAttribs->GetStartTime();
371 to.fEndTime = fpVisAttribs->GetEndTime();
372 to.fMarkerOrPolyline = isMarkerOrPolyline;
373 fTOList.push_back(to);
374 // For transient objects, colour, transformation, are kept in
375 // the TO, so should *not* be in the display list. As mentioned
376 // above, in some cases (display-by-time fading) we need to have
377 // independent control of colour. But for now transform and set
378 // colour for immediate display.
379 glPushMatrix();
380 G4OpenGLTransform3D oglt (fObjectTransformation);
381 glMultMatrixd (oglt.GetGLMatrix ());
382 if (transparency_enabled) {
383 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
384 } else {
385 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
386 }
387 (void) ExtraTOProcessing(visible, fTOList.size() - 1);
388 // Ignore return value of the above. If this visible does not use
389 // gl commands, a display list is created that is empty and not
390 // used.
391 glNewList (fDisplayListId, GL_COMPILE_AND_EXECUTE0x1301);
392 } else {
393 PO po(fDisplayListId, fObjectTransformation);
394 if (isPicking) po.fPickName = fPickName;
395 po.fColour = c;
396 po.fMarkerOrPolyline = isMarkerOrPolyline;
397 fPOList.push_back(po);
398 // For permanent objects, colour is kept in the PO, so should
399 // *not* be in the display list. This is so that sub-classes
400 // may implement colour modifications according to their own
401 // criteria, e.g., scen tree slider in Qt. But for now set
402 // colour for immediate display.
403 if (transparency_enabled) {
404 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
405 } else {
406 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
407 }
408 G4bool usesGLCommands = ExtraPOProcessing(visible, fPOList.size() - 1);
409 // Transients are displayed as they come (GL_COMPILE_AND_EXECUTE
410 // above) but persistents are compiled into display lists
411 // (GL_COMPILE only) and then drawn from the display lists with
412 // their fObjectTransformation as stored in fPOList. Thus,
413 // there is no need to do glMultMatrixd here. If
414 // ExtraPOProcessing says the visible object does not use gl
415 // commands, simply return and abandon further processing. It
416 // is assumed that all relevant information is kept in the
417 // POList.
418 if (!usesGLCommands) return false;
419 glNewList (fDisplayListId, GL_COMPILE0x1300);
420 }
421 } else { // Out of memory (or being used when display lists not required).
422 glPushMatrix();
423 G4OpenGLTransform3D oglt (fObjectTransformation);
424 glMultMatrixd (oglt.GetGLMatrix ());
425 if (transparency_enabled) {
426 glColor4d(c.GetRed(),c.GetGreen(),c.GetBlue(),c.GetAlpha());
427 } else {
428 glColor3d(c.GetRed(),c.GetGreen(),c.GetBlue());
429 }
430 }
431
432 if (fProcessing2D) {
433 // Push current 3D world matrices and load identity to define screen
434 // coordinates...
435 glMatrixMode (GL_PROJECTION0x1701);
436 glPushMatrix();
437 glLoadIdentity();
438 if (pViewer) {
439 pViewer->g4GlOrtho (-1., 1., -1., 1., -G4OPENGL_FLT_BIG1.e20, G4OPENGL_FLT_BIG1.e20);
440 }
441 glMatrixMode (GL_MODELVIEW0x1700);
442 glPushMatrix();
443 glLoadIdentity();
444 G4OpenGLTransform3D oglt (fObjectTransformation);
445 glMultMatrixd (oglt.GetGLMatrix ());
446 glDisable (GL_LIGHTING0x0B50);
447 } else {
448 glEnable (GL_LIGHTING0x0B50);
449 }
450
451 return true;
452}
453
454void G4OpenGLStoredSceneHandler::AddPrimitivePostamble()
455{
456 if (fProcessing2D) {
457 // Pop current 3D world matrices back again...
458 glMatrixMode (GL_PROJECTION0x1701);
459 glPopMatrix();
460 glMatrixMode (GL_MODELVIEW0x1700);
461 glPopMatrix();
462 }
463
464 // if ((glGetError() == GL_TABLE_TOO_LARGE) || (glGetError() == GL_OUT_OF_MEMORY)) { // Could close?
465 if (glGetError() == GL_OUT_OF_MEMORY0x0505) { // Could close?
466 G4cerr(*G4cerr_p) <<
467 "ERROR: G4OpenGLStoredSceneHandler::AddPrimitivePostamble: Failure"
468 " to allocate display List for fTopPODL - try OpenGL Immediated mode."
469 << G4endlstd::endl;
470 }
471 if (fMemoryForDisplayLists) {
472 glEndList();
473 if (glGetError() == GL_OUT_OF_MEMORY0x0505) { // Could close?
474 G4cerr(*G4cerr_p) <<
475 "ERROR: G4OpenGLStoredSceneHandler::AddPrimitivePostamble: Failure"
476 " to allocate display List for fTopPODL - try OpenGL Immediated mode."
477 << G4endlstd::endl;
478 }
479 }
480 if (fReadyForTransients || !fMemoryForDisplayLists) {
481 glPopMatrix();
482 }
483}
484
485void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polyline& polyline)
486{
487 G4bool furtherprocessing = AddPrimitivePreamble(polyline);
488 if (furtherprocessing) {
489 G4OpenGLSceneHandler::AddPrimitive(polyline);
490 AddPrimitivePostamble();
491 }
492}
493
494void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polymarker& polymarker)
495{
496 G4bool furtherprocessing = AddPrimitivePreamble(polymarker);
497 if (furtherprocessing) {
498 G4OpenGLSceneHandler::AddPrimitive(polymarker);
499 AddPrimitivePostamble();
500 }
501}
502
503void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Text& text)
504{
505 // Note: colour is still handled in
506 // G4OpenGLSceneHandler::AddPrimitive(const G4Text&), so it still
507 // gets into the display list
508 G4bool furtherprocessing = AddPrimitivePreamble(text);
509 if (furtherprocessing) {
510 G4OpenGLSceneHandler::AddPrimitive(text);
511 AddPrimitivePostamble();
512 }
513}
514
515void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Circle& circle)
516{
517 G4bool furtherprocessing = AddPrimitivePreamble(circle);
518 if (furtherprocessing) {
519 G4OpenGLSceneHandler::AddPrimitive(circle);
520 AddPrimitivePostamble();
521 }
522}
523
524void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Square& square)
525{
526 G4bool furtherprocessing = AddPrimitivePreamble(square);
527 if (furtherprocessing) {
528 G4OpenGLSceneHandler::AddPrimitive(square);
529 AddPrimitivePostamble();
530 }
531}
532
533void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Scale& scale)
534{
535 // Let base class split into primitives.
536 G4OpenGLSceneHandler::AddPrimitive(scale);
537}
538
539void G4OpenGLStoredSceneHandler::AddPrimitive (const G4Polyhedron& polyhedron)
540{
541 // Note: colour is still handled in
542 // G4OpenGLSceneHandler::AddPrimitive(const G4Polyhedron&), so it still
543 // gets into the display list
544 G4bool furtherprocessing = AddPrimitivePreamble(polyhedron);
545 if (furtherprocessing) {
546 G4OpenGLSceneHandler::AddPrimitive(polyhedron);
547 AddPrimitivePostamble();
548 }
549}
550
551void G4OpenGLStoredSceneHandler::BeginModeling () {
552 G4VSceneHandler::BeginModeling();
553 /* Debug...
554 fDisplayListId = glGenLists (1);
555 G4cout << "OGL::fDisplayListId (start): " << fDisplayListId << G4endl;
556 */
557}
558
559void G4OpenGLStoredSceneHandler::EndModeling () {
560 // Make a List which calls the other lists.
561 fTopPODL = glGenLists (1);
562 if (glGetError() == GL_OUT_OF_MEMORY0x0505) { // Could pre-allocate?
563 G4cerr(*G4cerr_p) <<
564 "ERROR: G4OpenGLStoredSceneHandler::EndModeling: Failure to allocate"
565 " display List for fTopPODL - try OpenGL Immediated mode."
566 << G4endlstd::endl;
567 } else {
568
569 glNewList (fTopPODL, GL_COMPILE0x1300); {
570 for (size_t i = 0; i < fPOList.size (); i++) {
571 glPushMatrix();
572 G4OpenGLTransform3D oglt (fPOList[i].fTransform);
573 glMultMatrixd (oglt.GetGLMatrix ());
574 if (fpViewer->GetViewParameters().IsPicking())
575 glLoadName(fPOList[i].fPickName);
576 glCallList (fPOList[i].fDisplayListId);
577 glPopMatrix();
578 }
579 }
580 glEndList ();
581
582 if (glGetError() == GL_OUT_OF_MEMORY0x0505) { // Could close?
583 G4cerr(*G4cerr_p) <<
584 "ERROR: G4OpenGLStoredSceneHandler::EndModeling: Failure to allocate"
585 " display List for fTopPODL - try OpenGL Immediated mode."
586 << G4endlstd::endl;
587 }
588 }
589
590 G4VSceneHandler::EndModeling ();
591}
592
593void G4OpenGLStoredSceneHandler::ClearStore () {
594
595 //G4cout << "G4OpenGLStoredSceneHandler::ClearStore" << G4endl;
596
597 G4VSceneHandler::ClearStore (); // Sets need kernel visit, etc.
598
599 // Delete OpenGL permanent display lists.
600 for (size_t i = 0; i < fPOList.size (); i++)
601 glDeleteLists (fPOList[i].fDisplayListId, 1);
602 if (fTopPODL) glDeleteLists (fTopPODL, 1);
603 fTopPODL = 0;
604
605 // Clear other lists, dictionary, etc.
606 fPOList.clear ();
607 fSolidMap.clear ();
608 ClearAndDestroyAtts();
609
610 // ...and clear transient store...
611 for (size_t i = 0; i < fTOList.size (); i++)
612 glDeleteLists(fTOList[i].fDisplayListId, 1);
613 fTOList.clear ();
614
615 fMemoryForDisplayLists = true;
616}
617
618void G4OpenGLStoredSceneHandler::ClearTransientStore ()
619{
620 //G4cout << "G4OpenGLStoredSceneHandler::ClearTransientStore" << G4endl;
621
622 // Delete OpenGL transient display lists and Transient Objects themselves.
623 for (size_t i = 0; i < fTOList.size (); i++)
624 glDeleteLists(fTOList[i].fDisplayListId, 1);
625 fTOList.clear ();
626
627 fMemoryForDisplayLists = true;
628
629 // Redraw the scene ready for the next event.
630 if (fpViewer) {
631 fpViewer -> SetView ();
632 fpViewer -> ClearView ();
633 fpViewer -> DrawView ();
634 }
635}
636
637
638#endif