0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / D3DHost / D3DHost_FrameBuffer.hxx
CommitLineData
62e1beed 1// Created on: 2015-06-10
2// Created by: Kirill Gavrilov
3// Copyright (c) 2015 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _D3DHost_FrameBuffer_HeaderFile
17#define _D3DHost_FrameBuffer_HeaderFile
18
19#include <OpenGl_FrameBuffer.hxx>
20
21struct IDirect3DDevice9;
d2eddacc 22struct IDirect3DSurface9;
62e1beed 23
24//! Implements bridge FBO for direct rendering to Direct3D surfaces.
25class D3DHost_FrameBuffer : public OpenGl_FrameBuffer
26{
27public:
28
29 //! Empty constructor.
30 Standard_EXPORT D3DHost_FrameBuffer();
31
32 //! Destructor, should be called after Release().
33 Standard_EXPORT ~D3DHost_FrameBuffer();
34
35 //! Releases D3D and OpenGL resources.
36 Standard_EXPORT virtual void Release (OpenGl_Context* theCtx) Standard_OVERRIDE;
37
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);
44
45 //! Binds Direct3D color buffer to OpenGL texture.
46 Standard_EXPORT Standard_Boolean registerD3dBuffer (const Handle(OpenGl_Context)& theCtx);
47
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;
51
52 //! Acquires D3D resource for OpenGL usage.
53 Standard_EXPORT virtual void LockSurface (const Handle(OpenGl_Context)& theCtx);
54
55 //! Releases D3D resource.
56 Standard_EXPORT virtual void UnlockSurface (const Handle(OpenGl_Context)& theCtx);
57
58 //! Returns D3D surface used as color buffer.
59 IDirect3DSurface9* D3dColorSurface() { return myD3dSurf; }
60
61 //! Returns WDDM hande for D3D color surface.
d2eddacc 62 void* D3dColorSurfaceShare() { return myD3dSurfShare; }
62e1beed 63
64protected:
65
66 using OpenGl_FrameBuffer::Init;
67
68protected:
69
70 IDirect3DSurface9* myD3dSurf; //!< D3D surface
d2eddacc 71 void* myD3dSurfShare; //!< D3D surface share handle in WDDM
72 void* myGlD3dDevice; //!< WGL/D3D device handle
73 void* myGlD3dSurf; //!< WGL/D3D surface handle
62e1beed 74 Standard_Integer myLockCount; //!< locking counter
75
76public:
77
92efcf78 78 DEFINE_STANDARD_RTTIEXT(D3DHost_FrameBuffer,OpenGl_FrameBuffer)
62e1beed 79
80};
81
82DEFINE_STANDARD_HANDLE(D3DHost_FrameBuffer, OpenGl_FrameBuffer)
83
84#endif // _D3DHost_FrameBuffer_HeaderFile