00001 #ifndef RenderArea_H 00002 #define RenderArea_H 00003 00004 #include <Inventor/misc/SoRef.h> 00005 #include <Inventor/sys/SoGL.h> 00006 #include <Inventor/actions/SoAction.h> 00007 #include <Inventor/ViewerComponents/SoRenderAreaCore.h> 00008 00009 #include <QOpenGLWidget> 00010 00011 #include <Inventor/sys/port.h> 00012 00013 #ifdef _WIN32 00014 # if defined(_DEBUG) 00015 # define __QTVIEWERCOMPONENTSLIB "fei.inventor.QtViewerComponentsD.lib" 00016 # else 00017 # define __QTVIEWERCOMPONENTSLIB "fei.inventor.QtViewerComponents.lib" 00018 # endif 00019 # ifndef QtViewerComponents_EXPORTS 00020 # ifndef OIV_DISABLE_AUTOLINK 00021 # pragma comment(lib,__QTVIEWERCOMPONENTSLIB) 00022 # endif 00023 # endif 00024 #endif 00025 00026 class SoNode; 00027 00043 class QTVIEWERCOMPONENTS_API RenderArea : public QOpenGLWidget, public SiRenderArea, public SiRenderAreaStereo 00044 { 00045 public: 00046 00050 RenderArea( QWidget* parent ); 00051 00053 virtual ~RenderArea(); 00054 00058 virtual void setSceneGraph(SoNode* sceneGraph); 00059 00063 virtual SoNode* getSceneGraph() const; 00064 00069 virtual void setClearPolicy(ClearPolicy policy); 00070 00074 virtual ClearPolicy getClearPolicy() const; 00075 00080 virtual void setClearColor(const SbColorRGBA& color); 00081 00085 virtual SbColorRGBA getClearColor() const; 00086 00091 virtual void setClearDepth(float depth); 00092 00096 virtual float getClearDepth() const; 00097 00101 virtual void setSize(const SbVec2i32& size); 00102 00106 virtual SbVec2i32 getSize() const; 00107 00111 virtual SbEventHandler<RenderEventArg&>& onStartRender(); 00112 00116 virtual void activateStereo( bool activated ); 00117 00121 virtual bool isStereoActivated() const; 00122 00126 virtual void setStereoParameters(SoStereoParameters* parameters); 00127 00131 virtual SoStereoParameters* getStereoParameters() const; 00132 00136 bool isRawStereoAvailable(); 00137 00138 private: 00139 00143 virtual RenderStatus render(); 00144 00150 virtual void initializeGL(); 00151 00159 virtual void resizeGL( int width, int height ); 00160 00167 virtual void paintGL(); 00168 00169 private: 00170 00175 SoRef<SoRenderAreaCore> m_renderAreaCore; 00176 00178 SoNode* m_sceneGraph; 00179 SiRenderArea::ClearPolicy m_policy; 00180 SbColorRGBA m_color; 00181 float m_depth; 00182 SbVec2i32 m_size; 00183 bool m_stereo; 00184 00185 00187 struct RenderAreaSaveRestore { 00188 RenderAreaSaveRestore(); 00189 virtual ~RenderAreaSaveRestore(); 00191 SbVec2i32 m_previousRenderingSize; 00193 GLuint m_backupFBOId; 00195 GLuint m_colorTextureId; 00197 GLuint m_depthStencilTextureId; 00199 SoRef<SoGLContext> m_context; 00200 }; 00201 00203 void saveRenderArea(); 00204 00206 void restoreRenderArea(); 00207 00208 RenderAreaSaveRestore m_restoreFBO; 00209 00210 private: 00211 00212 void init(); 00214 SoGLContext* m_context; 00215 00216 }; 00217 00218 #endif // RenderArea_H 00219 00220 00221