1 #ifndef COIN_SORENDERMANAGERP_H 2 #define COIN_SORENDERMANAGERP_H 3 4 /**************************************************************************\ 5 * Copyright (c) Kongsberg Oil & Gas Technologies AS 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are 10 * met: 11 * 12 * Redistributions of source code must retain the above copyright notice, 13 * this list of conditions and the following disclaimer. 14 * 15 * Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 19 * Neither the name of the copyright holder nor the names of its 20 * contributors may be used to endorse or promote products derived from 21 * this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 \**************************************************************************/ 35 36 #ifdef HAVE_CONFIG_H 37 #include <config.h> 38 #endif // HAVE_CONFIG_H 39 40 #include <vector> 41 42 #ifdef COIN_THREADSAFE 43 #include <Inventor/threads/SbMutex.h> 44 #endif // COIN_THREADSAFE 45 46 #include <Inventor/system/gl.h> 47 #include <Inventor/SbColor4f.h> 48 #include <Inventor/SoRenderManager.h> 49 #include <Inventor/SbViewportRegion.h> 50 #include <Inventor/elements/SoLazyElement.h> 51 #include <Inventor/sensors/SoNodeSensor.h> 52 #include <Inventor/misc/SoNotification.h> 53 54 class SbMatrix; 55 class SoNodeSensor; 56 class SoInfo; 57 class SoNode; 58 class SoGetBoundingBoxAction; 59 class SoGetMatrixAction; 60 class SoSearchAction; 61 class SbPList; 62 63 class SoRenderManagerP { 64 public: 65 SoRenderManagerP(SoRenderManager * publ); 66 ~SoRenderManagerP(); 67 68 void setClippingPlanes(void); 69 static void updateClippingPlanesCB(void * closure, SoSensor * sensor); 70 void getCameraCoordinateSystem(SbMatrix & matrix, 71 SbMatrix & inverse); 72 static void redrawshotTriggeredCB(void * data, SoSensor * sensor); 73 static void cleanup(void); 74 lock(void)75 void lock(void) { 76 #ifdef COIN_THREADSAFE 77 this->mutex.lock(); 78 #endif // COIN_THREADSAFE 79 } unlock(void)80 void unlock(void) { 81 #ifdef COIN_THREADSAFE 82 this->mutex.unlock(); 83 #endif // COIN_THREADSAFE 84 } 85 86 SoRenderManager * publ; 87 SoNodeSensor * rootsensor; 88 SoNode * scene; 89 SoCamera * camera; 90 float nearplanevalue; 91 SbBool doublebuffer; 92 SbBool isactive; 93 float stereooffset; 94 SoInfo * dummynode; 95 uint32_t overlaycolor; 96 SoColorPacker colorpacker; 97 SbViewportRegion stereostencilmaskvp; 98 GLubyte * stereostencilmask; 99 SbColor4f backgroundcolor; 100 int backgroundindex; 101 SbBool texturesenabled; 102 SbBool isrgbmode; 103 uint32_t redrawpri; 104 SoNodeSensor * clipsensor; 105 106 SoGetBoundingBoxAction * getbboxaction; 107 SoAudioRenderAction * audiorenderaction; 108 SoGetMatrixAction * getmatrixaction; 109 SoGLRenderAction * glaction; 110 SoSearchAction * searchaction; 111 SbBool deleteaudiorenderaction; 112 SbBool deleteglaction; 113 114 SoRenderManager::StereoMode stereostenciltype; 115 SoRenderManager::RenderMode rendermode; 116 SoRenderManager::StereoMode stereomode; 117 SoRenderManager::AutoClippingStrategy autoclipping; 118 119 SoRenderManagerRenderCB * rendercb; 120 void * rendercbdata; 121 SoOneShotSensor * redrawshot; 122 123 SbPList * superimpositions; 124 125 void invokePreRenderCallbacks(void); 126 void invokePostRenderCallbacks(void); 127 typedef std::pair<SoRenderManagerRenderCB *, void *> RenderCBTouple; 128 std::vector<RenderCBTouple> preRenderCallbacks; 129 std::vector<RenderCBTouple> postRenderCallbacks; 130 131 // "private" data 132 static SbBool touchtimer; 133 static SbBool cleanupfunctionset; 134 135 #ifdef COIN_THREADSAFE 136 SbMutex mutex; 137 #endif // COIN_THREADSAFE 138 }; 139 140 // ************************************************************************* 141 142 // This class inherits SoNodeSensor and overrides its notify() method 143 // to provide a means of debugging notifications on the root node. 144 // 145 // Good for debugging cases when there are continuous redraws due to 146 // scene graph changes we have no clue as to the source of. 147 // 148 // A sensor of this class is only made if the below debugging envvar 149 // is set. Otherwise, and ordinary SoNodeSensor is used instead. 150 151 class SoRenderManagerRootSensor : public SoNodeSensor { 152 typedef SoNodeSensor inherited; 153 154 public: SoRenderManagerRootSensor(SoSensorCB * func,void * data)155 SoRenderManagerRootSensor(SoSensorCB * func, void * data) : inherited(func, data) { } ~SoRenderManagerRootSensor()156 virtual ~SoRenderManagerRootSensor() { } 157 158 virtual void notify(SoNotList * l); 159 static SbBool debug(void); 160 161 private: 162 static int debugrootnotifications; 163 }; 164 165 // ************************************************************************* 166 167 168 #endif // COIN_SORENDERMANAGERP_H 169