Coin Logo http://www.sim.no/
http://www.coin3d.org/

SoRenderManager.h
00001 #ifndef COIN_SORENDERMANAGER_H
00002 #define COIN_SORENDERMANAGER_H
00003 
00004 /**************************************************************************\
00005  *
00006  *  This file is part of the Coin 3D visualization library.
00007  *  Copyright (C) by Kongsberg Oil & Gas Technologies.
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU General Public License
00011  *  ("GPL") version 2 as published by the Free Software Foundation.
00012  *  See the file LICENSE.GPL at the root directory of this source
00013  *  distribution for additional information about the GNU GPL.
00014  *
00015  *  For using Coin with software that can not be combined with the GNU
00016  *  GPL, and for taking advantage of the additional benefits of our
00017  *  support services, please contact Kongsberg Oil & Gas Technologies
00018  *  about acquiring a Coin Professional Edition License.
00019  *
00020  *  See http://www.coin3d.org/ for more information.
00021  *
00022  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
00023  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
00024  *
00025 \**************************************************************************/
00026 
00027 #include <Inventor/SbColor4f.h>
00028 #include <Inventor/SbVec2s.h>
00029 #include <Inventor/actions/SoGLRenderAction.h>
00030 
00031 class SbViewportRegion;
00032 class SoEvent;
00033 class SoGLRenderAction;
00034 class SoAudioRenderAction;
00035 class SoNode;
00036 class SoCamera;
00037 class SoNodeSensor;
00038 class SoOneShotSensor;
00039 class SoSensor;
00040 class SoRenderManagerP;
00041 
00042 typedef void SoRenderManagerRenderCB(void * userdata, class SoRenderManager * mgr);
00043 
00044 class COIN_DLL_API SoRenderManager {
00045 public:
00046 
00047   class COIN_DLL_API Superimposition {
00048   public:
00049     enum StateFlags {
00050       ZBUFFERON    = 0x0001,
00051       CLEARZBUFFER = 0x0002,
00052       AUTOREDRAW   = 0x0004,
00053       BACKGROUND   = 0x0008
00054     };
00055 
00056     Superimposition(SoNode * scene,
00057                     SbBool enabled,
00058                     SoRenderManager * manager,
00059                     uint32_t flags);
00060     ~Superimposition();
00061 
00062     void render(SoGLRenderAction * action, SbBool clearcolorbuffer = FALSE);
00063     void setEnabled(SbBool yes);
00064     int getStateFlags(void) const;
00065     void setTransparencyType(SoGLRenderAction::TransparencyType transparencytype);
00066 
00067   private:
00068     static void changeCB(void * data, SoSensor * sensor);
00069     class SuperimpositionP * pimpl;
00070   };
00071 
00072   enum RenderMode {
00073     AS_IS,
00074     WIREFRAME,
00075     POINTS,
00076     WIREFRAME_OVERLAY,
00077     HIDDEN_LINE,
00078     BOUNDING_BOX
00079   };
00080 
00081   enum StereoMode {
00082     MONO,
00083     ANAGLYPH,
00084     SEPARATE_OUTPUT,
00085     QUAD_BUFFER = SEPARATE_OUTPUT,
00086     INTERLEAVED_ROWS,
00087     INTERLEAVED_COLUMNS
00088   };
00089 
00090   enum BufferType {
00091     BUFFER_SINGLE,
00092     BUFFER_DOUBLE
00093   };
00094 
00095   enum AutoClippingStrategy {
00096     NO_AUTO_CLIPPING,
00097     FIXED_NEAR_PLANE,
00098     VARIABLE_NEAR_PLANE
00099   };
00100 
00101   SoRenderManager(void);
00102   virtual ~SoRenderManager();
00103 
00104   virtual void render(const SbBool clearwindow = TRUE,
00105                       const SbBool clearzbuffer = TRUE);
00106 
00107   virtual void render(SoGLRenderAction * action,
00108                       const SbBool initmatrices = TRUE,
00109                       const SbBool clearwindow = TRUE,
00110                       const SbBool clearzbuffer = TRUE);
00111 
00112   Superimposition * addSuperimposition(SoNode * scene,
00113                                        uint32_t flags =
00114                                        Superimposition::AUTOREDRAW |
00115                                        Superimposition::ZBUFFERON  |
00116                                        Superimposition::CLEARZBUFFER);
00117 
00118   void removeSuperimposition(Superimposition * s);
00119 
00120   virtual void setSceneGraph(SoNode * const sceneroot);
00121   virtual SoNode * getSceneGraph(void) const;
00122 
00123   void setCamera(SoCamera * camera);
00124   SoCamera * getCamera(void) const;
00125 
00126   void setAutoClipping(AutoClippingStrategy autoclipping);
00127   void attachRootSensor(SoNode * const sceneroot);
00128   void attachClipSensor(SoNode * const sceneroot);
00129   void detachRootSensor(void);
00130   void detachClipSensor(void);
00131 
00132   AutoClippingStrategy getAutoClipping(void) const;
00133   void setNearPlaneValue(float value);
00134   float getNearPlaneValue(void) const;
00135   void setTexturesEnabled(const SbBool onoff);
00136   SbBool isTexturesEnabled(void) const;
00137   void setDoubleBuffer(const SbBool enable);
00138   SbBool isDoubleBuffer(void) const;
00139   void setRenderMode(const RenderMode mode);
00140   RenderMode getRenderMode(void) const;
00141   void setStereoMode(const StereoMode mode);
00142   StereoMode getStereoMode(void) const;
00143   void setStereoOffset(const float offset);
00144   float getStereoOffset(void) const;
00145 
00146   void setRenderCallback(SoRenderManagerRenderCB * f,
00147                          void * const userData = NULL);
00148 
00149   SbBool isAutoRedraw(void) const;
00150   void setRedrawPriority(const uint32_t priority);
00151   uint32_t getRedrawPriority(void) const;
00152 
00153   static void nodesensorCB(void * data, SoSensor *);
00154   static void prerendercb(void * userdata, SoGLRenderAction * action);
00155 
00156   void reinitialize(void);
00157   void scheduleRedraw(void);
00158   void setWindowSize(const SbVec2s & newsize);
00159   const SbVec2s & getWindowSize(void) const;
00160   void setSize(const SbVec2s & newsize);
00161   const SbVec2s & getSize(void) const;
00162   void setOrigin(const SbVec2s & newOrigin);
00163   const SbVec2s & getOrigin(void) const;
00164   void setViewportRegion(const SbViewportRegion & newRegion);
00165   const SbViewportRegion & getViewportRegion(void) const;
00166   void setBackgroundColor(const SbColor4f & color);
00167   const SbColor4f & getBackgroundColor(void) const;
00168   void setBackgroundIndex(const int index);
00169   int getBackgroundIndex(void) const;
00170   void setRGBMode(const SbBool onOrOff);
00171   SbBool isRGBMode(void) const;
00172   virtual void activate(void);
00173   virtual void deactivate(void);
00174 
00175   void setAntialiasing(const SbBool smoothing, const int numPasses);
00176   void getAntialiasing(SbBool & smoothing, int & numPasses) const;
00177   void setGLRenderAction(SoGLRenderAction * const action);
00178   SoGLRenderAction * getGLRenderAction(void) const;
00179   void setAudioRenderAction(SoAudioRenderAction * const action);
00180   SoAudioRenderAction * getAudioRenderAction(void) const;
00181 
00182   static void enableRealTimeUpdate(const SbBool flag);
00183   static SbBool isRealTimeUpdateEnabled(void);
00184   static uint32_t getDefaultRedrawPriority(void);
00185 
00186   void addPreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
00187   void removePreRenderCallback(SoRenderManagerRenderCB * cb, void * data);
00188 
00189   void addPostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
00190   void removePostRenderCallback(SoRenderManagerRenderCB * cb, void * data);
00191 
00192 protected:
00193   int isActive(void) const;
00194   void redraw(void);
00195 
00196   void renderScene(SoGLRenderAction * action,
00197                    SoNode * scene,
00198                    uint32_t clearmask);
00199 
00200   void actuallyRender(SoGLRenderAction * action,
00201                       const SbBool initmatrices = TRUE,
00202                       const SbBool clearwindow = TRUE,
00203                       const SbBool clearzbuffer = TRUE);
00204 
00205   void renderSingle(SoGLRenderAction * action,
00206                     SbBool initmatrices,
00207                     SbBool clearwindow,
00208                     SbBool clearzbuffer);
00209 
00210   void renderStereo(SoGLRenderAction * action,
00211                     SbBool initmatrices,
00212                     SbBool clearwindow,
00213                     SbBool clearzbuffer);
00214 
00215   void initStencilBufferForInterleavedStereo(void);
00216   void clearBuffers(SbBool color, SbBool depth);
00217 
00218 private:
00219   SoRenderManagerP * pimpl;
00220   friend class SoRenderManagerP;
00221   friend class SoSceneManager;
00222   friend class Superimposition;
00223 
00224 }; // SoRenderManager
00225 
00226 #endif // !COIN_SORENDERMANAGER_H

Copyright © 1998-2010 by Kongsberg Oil & Gas Technologies. All rights reserved.

Generated for Coin by Doxygen 1.7.5.1.