1 // Created on: 2015-06-10
2 // Created by: Kirill Gavrilov
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _D3DHost_FrameBuffer_HeaderFile
17 #define _D3DHost_FrameBuffer_HeaderFile
19 #include <OpenGl_FrameBuffer.hxx>
21 struct IDirect3DDevice9;
22 struct IDirect3DSurface9;
24 //! Implements bridge FBO for direct rendering to Direct3D surfaces.
25 class D3DHost_FrameBuffer : public OpenGl_FrameBuffer
29 //! Empty constructor.
30 Standard_EXPORT D3DHost_FrameBuffer();
32 //! Destructor, should be called after Release().
33 Standard_EXPORT ~D3DHost_FrameBuffer();
35 //! Releases D3D and OpenGL resources.
36 Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
38 //! Initializes OpenGL FBO for Direct3D interoperability.
39 Standard_EXPORT Standard_Boolean Init (const Handle(OpenGl_Context)& theCtx,
40 IDirect3DDevice9* theD3DDevice,
41 const Standard_Boolean theIsD3dEx,
42 const Standard_Integer theSizeX,
43 const Standard_Integer theSizeY);
45 //! Binds Direct3D color buffer to OpenGL texture.
46 Standard_EXPORT Standard_Boolean registerD3dBuffer (const Handle(OpenGl_Context)& theCtx);
48 //! Binds Direct3D objects for OpenGL drawing.
49 //! Should be called before LockSurface() and followed by UnlockSurface();
50 Standard_EXPORT virtual void BindBuffer (const Handle(OpenGl_Context)& theCtx) Standard_OVERRIDE;
52 //! Acquires D3D resource for OpenGL usage.
53 Standard_EXPORT virtual void LockSurface (const Handle(OpenGl_Context)& theCtx);
55 //! Releases D3D resource.
56 Standard_EXPORT virtual void UnlockSurface (const Handle(OpenGl_Context)& theCtx);
58 //! Returns D3D surface used as color buffer.
59 IDirect3DSurface9* D3dColorSurface() { return myD3dSurf; }
61 //! Returns WDDM hande for D3D color surface.
62 void* D3dColorSurfaceShare() { return myD3dSurfShare; }
66 using OpenGl_FrameBuffer::Init;
70 IDirect3DSurface9* myD3dSurf; //!< D3D surface
71 void* myD3dSurfShare; //!< D3D surface share handle in WDDM
72 void* myGlD3dDevice; //!< WGL/D3D device handle
73 void* myGlD3dSurf; //!< WGL/D3D surface handle
74 Standard_Integer myLockCount; //!< locking counter
78 DEFINE_STANDARD_RTTIEXT(D3DHost_FrameBuffer,OpenGl_FrameBuffer)
82 DEFINE_STANDARD_HANDLE(D3DHost_FrameBuffer, OpenGl_FrameBuffer)
84 #endif // _D3DHost_FrameBuffer_HeaderFile