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 : VSG (MMM YYYY) 00022 **=======================================================================*/ 00023 00024 #ifndef _SO_PBUFFER_H_ 00025 #define _SO_PBUFFER_H_ 00026 00027 #include <Inventor/SbBasic.h> 00028 #include <Inventor/SbLinear.h> 00029 #include <Inventor/SoGLRenderToBuffer.h> 00030 #include <Inventor/helpers/SbGlContextHelper.h> 00031 00032 // In order to make this interface system-independent we need a 00033 // portable opaque type that can contain any of the system-dependent 00034 // types used internally (eg. XID, GLXContext, HANDLE, HDC, etc). 00035 #ifndef _SBHANDLE_ 00036 #define _SBHANDLE_ 1 00037 typedef void *SbHandle; 00038 #endif 00039 00040 class SoGLContext; 00041 class SoGLGraphicDevice; 00042 class SoGLGraphicConfig; 00043 class SoGLWindow; 00044 class SoDEPRECATED SoPBuffer : public SoGLRenderToBuffer { 00073 00074 public: 00080 SoPBuffer(); 00081 00085 ~SoPBuffer(); 00086 00096 static SbBool isAvailable(SbGlContextHelper::Display display = NULL); 00097 00103 SbBool create(SbVec2s size); 00104 00110 SbBool create(SbVec2i32 size); 00115 SbBool makeCurrent(); 00116 00121 void disable(); 00122 00126 void shareCurrentContext(); 00127 00133 SbBool resize(const SbVec2s &size); 00134 00140 SbBool resize(const SbVec2i32 &size); 00141 00145 SbVec2s getSize() const; 00146 00150 const SbVec2i32& getSize_i32() const; 00151 00152 00158 void setPixelFormat(int format); 00159 00165 int getPixelFormat(); 00166 00171 void setRenderToTexture(SbBool enable, TextureFormat format = TEXTURE_RGB, TextureTarget target = TEXTURE_2D, 00172 SbBool autoMipmap = FALSE, SbBool hasDepth = FALSE); 00173 00178 virtual SbBool bindToTexture(SbBool bindDepth = FALSE, GLuint texObj=-1); 00179 00185 SbBool releaseTexImage(SbBool bindDepth = FALSE); 00186 00187 00191 SbBool selectCubeMapFace(CubeMapTextureFace face); 00192 00196 SoGLGraphicConfigTemplate* getGraphicConfigTemplate(); 00197 00198 00202 void setGraphicConfigTemplate(SoGLGraphicConfigTemplate* gTemplate); 00203 00204 00205 00206 00207 private: 00208 00209 // ----- Methods using system-dependent types ----- 00210 // (only needed for special cases) 00211 00219 virtual void setDisplayConnection(SbGlContextHelper::Display display); 00220 00227 virtual void setContextForSharing(SoGLContext *context); 00228 00236 SbHandle getHandle(); 00237 00242 SbGlContextHelper::Display getDisplay(); 00243 00251 SoGLContext* getContext(); 00252 00256 virtual SbBool isPBuffer() 00257 { return TRUE; } 00258 00259 private: 00260 00261 // register in database 00262 static void initClass(); 00263 // unregister from database 00264 static void exitClass(); 00265 00267 void copyToTexture(); 00268 00269 // Gets the current graphic device. 00270 SoGLGraphicDevice* getGraphicDevice(); 00271 00272 // Gets the current graphic configuration. 00273 SoGLGraphicConfig* getGraphicConfig(); 00274 00277 virtual void setFaceTarget(int faceTarget); 00278 00279 // Enables alpha channel for pbuffer 00280 void setAlpha( SbBool enable ) { m_needAlpha = enable; } // Disabled by default 00281 SbBool hasAlpha() const { return m_needAlpha; } 00282 00288 virtual SbBool isUsingWglRenderToTex(); 00289 00290 private: 00291 SbHandle m_fbconfig; 00292 SbHandle m_pbuffer ; 00293 00294 SbGlContextHelper::Display m_display; 00295 SbBool m_displayIsInternal; 00296 00297 // handles if user request to share the PBuffer with an existing context 00298 SoGLContext *m_shareContext; 00299 bool m_shared; 00300 00301 00302 SbVec2i32 m_size_i32; 00303 SbVec2s m_size; 00304 00305 SoGLGraphicDevice* m_currentGraphicDevice; 00306 SbBool m_currentGraphicConfigIsUsed; 00307 SoGLGraphicConfig* m_currentGraphicConfig; 00308 SbBool m_currentGraphicDeviceIsUsed; 00309 SbBool m_renderToTexture; 00310 TextureFormat m_textureFormat; 00311 TextureTarget m_textureTarget; 00312 bool m_autoMipmap; 00313 00314 int m_cubeMapFaceAttr; 00315 int m_faceTarget; 00316 00317 private: 00318 void cleanUpCreate( SoGLWindow* glWindow ); 00319 00320 // this is our openGL context 00321 SoGLContext* m_glContext; 00322 // Context here before we bind our context. 00323 // Used only with OIV_COMPAT_CONTEXT_80 > 0 where we have to manually manage contexts. 00324 SoGLContext* m_prevContext; 00325 00326 // Needed for a PFD with alpha channel enabled (Windows only) 00327 SbBool m_needAlpha; 00328 00329 bool m_isDisabled; 00330 00331 // handle OIV_PBUFFER_DEBUG envvar 00332 static SbBool s_debugFlag; 00333 static void debugPrint(const char *format, void *p1 = NULL, void *p2 = NULL, void *p3 = NULL); 00334 00335 // handle OIV_PBUFFER_ENABLE envvar 00336 static SbBool s_isForcedDisabled; 00337 00338 // handle OIV_COMPAT_CONTEXT_80 envar 00339 static int s_oivCompatibilityMode; 00340 00341 // handle WGL_NV_render_depth_texture extension 00342 bool m_WGL_NV_render_depth_texture_available; 00343 }; 00344 00345 #endif //_SO_PBUFFER_H_ 00346 00347