00001 /* 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 */ 00020 00021 #pragma once 00022 00023 #include <Inventor/misc/SoRefCounter.h> 00024 #include <Inventor/actions/SoGLRenderAction.h> 00025 #include <Inventor/SbColorRGBA.h> 00026 #include <Inventor/SbVec.h> 00027 #include <Inventor/SbString.h> 00028 #include <Inventor/SbViewportRegion.h> 00029 #include <Inventor/SbEventHandler.h> 00030 #include <Inventor/SbEventArg.h> 00031 #include <Inventor/SbPImpl.h> 00032 #include <Inventor/image/SbRasterImage.h> 00033 #include <Inventor/ViewerComponents/SiRenderArea.h> 00034 #include <Inventor/ViewerComponents/SiRenderAreaAntialiasing.h> 00035 #include <Inventor/ViewerComponents/SiRenderAreaTransparency.h> 00036 00037 class SoGLContext; 00038 class SoBufferObject; 00039 class SoRenderAreaCore; 00040 class SoNode; 00041 class SoSceneManager; 00042 00043 00044 SO_PIMPL_BASE_PUBLIC_DECLARATION(SoOffscreenRenderArea); 00045 00160 class SoOffscreenRenderArea : public SoRefCounter, public SiRenderArea, public SiRenderAreaAntialiasing, public SiRenderAreaTransparency 00161 { 00162 SO_PIMPL_BASE_PUBLIC_HEADER(SoOffscreenRenderArea); 00163 00164 public: 00170 SoOffscreenRenderArea(); 00171 00175 SoOffscreenRenderArea(SoGLContext* glContex); 00176 00181 SoOffscreenRenderArea(SoRenderAreaCore* renderAreaCore); 00182 00186 ~SoOffscreenRenderArea(); 00187 00191 virtual void setSceneGraph(SoNode *newScene); 00192 00196 virtual SoNode* getSceneGraph() const; 00197 00201 void setViewportRegion(const SbViewportRegion &newRegion); 00202 00206 SbViewportRegion getViewportRegion() const; 00207 00217 virtual void setTransparencyType(SoGLRenderAction::TransparencyType type); 00218 00222 virtual SoGLRenderAction::TransparencyType getTransparencyType() const; 00223 00227 SoSceneManager* getSceneManager() const; 00228 00230 enum OutputFormat 00231 { 00233 RGB, 00234 00236 RGBA 00237 }; 00238 00275 bool renderToFile( const SbString& filename, OutputFormat outputFormat = RGB ) const; 00276 00277 00295 bool renderToBuffer( SoBufferObject* buffer, OutputFormat outputFormat = RGB ) const; 00296 00319 void setTile(SbVec2i32 size, int numEdgePixels); 00320 00324 SbVec2i32 getTileSize() const; 00325 00329 int getNumEdgePixels() const; 00330 00334 virtual ClearPolicy getClearPolicy() const; 00335 00343 virtual void setClearPolicy(ClearPolicy policy); 00344 00353 virtual void setClearColor(const SbColorRGBA& color); 00354 00358 virtual SbColorRGBA getClearColor() const; 00359 00368 virtual void setClearDepth(float depth); 00369 00373 virtual float getClearDepth() const; 00374 00378 virtual void setSize(const SbVec2i32& size); 00379 00383 virtual SbVec2i32 getSize() const; 00384 00388 virtual void setGLRenderAction( SoGLRenderAction* glAction ); 00389 00393 virtual SoGLRenderAction* getGLRenderAction() const; 00394 00398 virtual SbEventHandler<RenderEventArg&>& onStartRender(); 00399 00403 static SbVec2i32 getMaxTileSize(); 00404 00409 virtual void setAntialiasingMode(SoSceneManager::AntialiasingMode mode); 00410 00414 virtual SoSceneManager::AntialiasingMode getAntialiasingMode() const; 00415 00421 virtual void setAntialiasingQuality(float quality); 00422 00426 virtual float getAntialiasingQuality() const; 00427 00432 virtual RenderStatus render(); 00433 00438 struct EventArg : public SbEventArg 00439 { 00440 public: 00441 00445 const SoOffscreenRenderArea* getSource() const; 00446 00450 int getNumTiles() const; 00451 00455 const SbVec2i32& getOrigin() const; 00456 00461 const SbRasterImage& getTile() const; 00462 00463 private: 00464 friend class inventor::impl::SoOffscreenRenderAreaImpl; 00465 00467 EventArg(const SoOffscreenRenderArea* renderarea, int numTiles, SoBufferObject* buffer); 00468 ~EventArg(); 00469 00470 const SoOffscreenRenderArea* m_renderarea; 00471 SbVec2i32 m_origin; 00472 int m_numTiles; 00473 SbRasterImage* m_tile; 00474 }; 00475 00479 SbEventHandler<EventArg&> onTileRendered; 00480 00481 private: 00482 00489 virtual RenderStatus render( const SbVec4i32& window ); 00490 00491 #if 1 SoDEPRECATED 00499 virtual RenderStatus render( const SbVec4s &window ) 00500 { 00501 return render( SbVec4i32( window ) ); 00502 } 00503 #endif /* 1 */ 00504 00505 }; 00506 00507 00508