0029138: Visualization - D3DHost_FrameBuffer should provide software fallback when...
[occt.git] / src / D3DHost / D3DHost_FrameBuffer.hxx
index 22eed6e..ecfabc1 100644 (file)
@@ -19,6 +19,7 @@
 #include <OpenGl_FrameBuffer.hxx>
 
 struct IDirect3DDevice9;
+struct IDirect3DSurface9;
 
 //! Implements bridge FBO for direct rendering to Direct3D surfaces.
 class D3DHost_FrameBuffer : public OpenGl_FrameBuffer
@@ -34,13 +35,27 @@ public:
   //! Releases D3D and OpenGL resources.
   Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
 
-  //! Initializes OpenGL FBO for Direct3D interoperability.
+  //! Initializes OpenGL FBO for Direct3D interoperability or in fallback mode.
   Standard_EXPORT Standard_Boolean Init (const Handle(OpenGl_Context)& theCtx,
                                          IDirect3DDevice9*             theD3DDevice,
                                          const Standard_Boolean        theIsD3dEx,
                                          const Standard_Integer        theSizeX,
                                          const Standard_Integer        theSizeY);
 
+  //! Initializes OpenGL FBO for Direct3D interoperability.
+  Standard_EXPORT Standard_Boolean InitD3dInterop (const Handle(OpenGl_Context)& theCtx,
+                                                   IDirect3DDevice9*             theD3DDevice,
+                                                   const Standard_Boolean        theIsD3dEx,
+                                                   const Standard_Integer        theSizeX,
+                                                   const Standard_Integer        theSizeY);
+
+  //! Initializes OpenGL FBO + Direct3D surface for copying memory using fallback.
+  Standard_EXPORT Standard_Boolean InitD3dFallback (const Handle(OpenGl_Context)& theCtx,
+                                                    IDirect3DDevice9*             theD3DDevice,
+                                                    const Standard_Boolean        theIsD3dEx,
+                                                    const Standard_Integer        theSizeX,
+                                                    const Standard_Integer        theSizeY);
+
   //! Binds Direct3D color buffer to OpenGL texture.
   Standard_EXPORT Standard_Boolean registerD3dBuffer (const Handle(OpenGl_Context)& theCtx);
 
@@ -57,8 +72,11 @@ public:
   //! Returns D3D surface used as color buffer.
   IDirect3DSurface9* D3dColorSurface()      { return myD3dSurf; }
 
-  //! Returns WDDM hande for D3D color surface.
-  HANDLE             D3dColorSurfaceShare() { return myD3dSurfShare; }
+  //! Returns WDDM handle for D3D color surface.
+  void*              D3dColorSurfaceShare() { return myD3dSurfShare; }
+
+  //! Returns TRUE if FBO has been initialized without WGL/D3D interop.
+  Standard_Boolean   D3dFallback() const { return myD3dFallback; }
 
 protected:
 
@@ -67,14 +85,15 @@ protected:
 protected:
 
   IDirect3DSurface9* myD3dSurf;      //!< D3D surface
-  HANDLE             myD3dSurfShare; //!< D3D surface share handle in WDDM
-  HANDLE             myGlD3dDevice;  //!< WGL/D3D device  handle
-  HANDLE             myGlD3dSurf;    //!< WGL/D3D surface handle
+  void*              myD3dSurfShare; //!< D3D surface share handle in WDDM
+  void*              myGlD3dDevice;  //!< WGL/D3D device  handle
+  void*              myGlD3dSurf;    //!< WGL/D3D surface handle
   Standard_Integer   myLockCount;    //!< locking counter
+  Standard_Boolean   myD3dFallback;  //!< indicates that FBO has been initialized without WGL/D3D interop
 
 public:
 
-  DEFINE_STANDARD_RTTI(D3DHost_FrameBuffer, OpenGl_FrameBuffer)
+  DEFINE_STANDARD_RTTIEXT(D3DHost_FrameBuffer,OpenGl_FrameBuffer)
 
 };