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 ** Author : C. OGNIER (Dec 2004) 00022 **=======================================================================*/ 00023 00024 00025 #ifndef _SO_RENDER_TO_TEXTURE_PROPERTY_ 00026 #define _SO_RENDER_TO_TEXTURE_PROPERTY_ 00027 00028 #include <Inventor/nodes/SoNode.h> 00029 #include <Inventor/fields/SoMFNode.h> 00030 #include <Inventor/fields/SoSFEnum.h> 00031 #include <Inventor/fields/SoSFColor.h> 00032 #include <Inventor/fields/SoMFPath.h> 00033 #include <Inventor/fields/SoSFVec2s.h> 00034 #include <Inventor/fields/SoSFTrigger.h> 00035 #include <Inventor/actions/SoGLRenderAction.h> 00036 #include <Inventor/sensors/SoFieldSensor.h> 00037 #include <Inventor/components/SoGLGraphicConfigTemplate.h> 00038 #include <Inventor/sys/SoGLType.h> 00039 #include <Inventor/helpers/SbGlContextHelper.h> 00040 00041 class SoGLRenderToBuffer; 00042 class SoRenderToTexturePropertyImpl_fbo; 00043 class SoRenderToTexturePropertyImpl_PBuffer; 00044 class SoGLTexture; 00045 00088 class SoRenderToTextureProperty : public SoNode { 00089 00090 SO_NODE_HEADER(SoRenderToTextureProperty); 00091 00092 public: 00093 00094 SoRenderToTextureProperty(); 00095 00097 enum UpdatePolicy { 00101 EACH_FRAME, 00106 WHEN_NEEDED, 00110 ON_TRIGGER 00111 }; 00112 00114 enum Component { 00119 RGB, 00123 RGB_TRANSPARENCY, 00124 RGB_ALPHA = RGB_TRANSPARENCY, 00128 DEPTH 00129 }; 00130 00131 00132 // Fields 00148 SoMFNode node; 00149 00165 SoMFPath path; 00166 00171 SoSFEnum updatePolicy; 00172 00176 SoSFColor backgroundColor; 00177 00184 SoSFVec2s size; 00185 00190 SoSFEnum component; 00191 00196 SoSFTrigger trigger; 00197 00201 void setGLRenderAction(SoGLRenderAction* ra); 00202 00206 SoGLRenderAction* getGLRenderAction() const; 00207 00211 void setGraphicConfigTemplate(SoGLGraphicConfigTemplate* gct); 00212 00216 SoGLGraphicConfigTemplate* getGraphicConfigTemplate(); 00217 00223 void setContextForSharing(SoGLContext *context); 00224 00225 00226 private: 00227 virtual void GLRender(SoGLRenderAction *action); 00228 00229 private: 00230 static void initClass(); 00231 static void exitClass(); 00232 00234 int getNumComponents() const; 00235 00237 void setGCParams(SbVec4i32 params); 00238 00239 void setForTextureCubeMap(SbBool isCubeMap); 00240 00241 void useAutoMipmap(SbBool mm); 00242 00243 SbBool isAutoMipmap() {return m_autoMipmap;}; 00244 00246 void bindToTexture(SoState* state, SoGLTexture* texture); 00247 00248 void setDisplay(SbGlContextHelper::Display handle); 00249 00252 SbBool doRendering(SoGLRenderAction*); 00253 00255 bool isTriggerCalled() { return m_triggerCalled; } 00256 00265 void doTrigger(); 00266 00267 private: 00268 ~SoRenderToTextureProperty(); 00269 00271 virtual void notify( SoNotList *list ); 00272 00273 private: 00274 00276 SbBool anySceneGraph() const; 00277 00279 SbBool m_textureCubeMapEnabled; 00280 00282 SbBool m_autoMipmap; 00283 00285 SoGLContext *m_shareContext; 00286 00288 SoGLGraphicConfigTemplate* m_gTemplate; 00289 00291 SoGLRenderAction* m_renderAction; 00292 00294 SbVec4i32 m_gtParams; 00295 00297 SbGlContextHelper::Display m_dpyHandle; 00298 00300 SoGLTexture* m_texture; 00301 GLuint m_textureToRenderId; 00302 00304 SoRenderToTexturePropertyImpl_PBuffer* m_implPBuffer; 00305 00307 SoRenderToTexturePropertyImpl_fbo* m_implFbo; 00308 00311 bool m_triggerCalled; 00312 00315 bool m_fieldChanged; 00316 }; 00317 00318 #endif /* _SO_RENDER_TO_TEXTURE_PROPERTY_ */ 00319 00320 00321