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_View_HeaderFile
17 #define _D3DHost_View_HeaderFile
19 #include <D3DHost_FrameBuffer.hxx>
20 #include <OpenGl_View.hxx>
21 #include <OpenGl_Workspace.hxx>
23 class D3DHost_GraphicDriver;
25 struct IDirect3DDevice9;
26 typedef struct _D3DPRESENT_PARAMETERS_ D3DPRESENT_PARAMETERS;
28 //! The D3D host view implementation that overrides rendering methods.
29 class D3DHost_View : public OpenGl_View
35 Standard_EXPORT D3DHost_View (const Handle(Graphic3d_StructureManager)& theMgr,
36 const Handle(D3DHost_GraphicDriver)& theDriver,
37 const Handle(OpenGl_Caps)& theCaps,
38 OpenGl_StateCounter* theCounter);
40 //! Default destructor.
41 Standard_EXPORT virtual ~D3DHost_View();
43 //! Release OpenGL resources.
44 Standard_EXPORT virtual void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx) Standard_OVERRIDE;
46 //! Creates and maps rendering window to the view.
47 Standard_EXPORT virtual void SetWindow (const Handle(Graphic3d_CView)& theParentVIew,
48 const Handle(Aspect_Window)& theWindow,
49 const Aspect_RenderingContext theContext) Standard_OVERRIDE;
51 //! Resizes the window.
52 Standard_EXPORT virtual void Resized() Standard_OVERRIDE;
54 //! Redraw the all content.
55 Standard_EXPORT virtual void Redraw() Standard_OVERRIDE;
57 //! Redraw only immediate layer.
58 Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
60 //! Fill in the dictionary with diagnostic info.
61 //! Should be called within rendering thread.
62 Standard_EXPORT virtual void DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
63 Graphic3d_DiagnosticInfo theFlags) const Standard_OVERRIDE;
67 //! @return true if IDirect3DDevice9Ex device has been created
68 bool isD3dEx() const { return myIsD3dEx; }
70 //! Access Direct3D device instance.
71 IDirect3DDevice9* D3dDevice() const { return myD3dDevice; }
73 //! Return D3D/WGL FBO.
74 const Handle(D3DHost_FrameBuffer)& D3dWglBuffer() const { return myD3dWglFbo; }
76 //! Return D3D surface.
77 Standard_EXPORT IDirect3DSurface9* D3dColorSurface() const;
82 Standard_EXPORT static TCollection_AsciiString d3dFormatError (const long theErrCode);
84 //! Initialize the D3D library.
85 Standard_EXPORT bool d3dInitLib();
87 //! Initialize Direct3D output device.
88 Standard_EXPORT bool d3dInit();
90 //! Reset Direct3D output settings. Could be used to switch windowed/fullscreen modes.
91 //! Use very carefully! Most objects should be released before and recreated after!
92 Standard_EXPORT bool d3dReset();
94 //! (Re-)create D3D surface.
95 Standard_EXPORT bool d3dCreateRenderTarget();
97 //! Starts the scene render.
98 //! Clears the backbuffer and sets the device to start rendering to it.
99 Standard_EXPORT void d3dBeginRender();
101 //! Ends the scene render.
102 Standard_EXPORT void d3dEndRender();
104 //! Presents to the screen.
105 Standard_EXPORT bool d3dSwap();
109 IDirect3D9* myD3dLib; //!< Direct3D library instance
110 IDirect3DDevice9* myD3dDevice; //!< Direct3D device object
111 NCollection_Handle<D3DPRESENT_PARAMETERS>
112 myD3dParams; //!< parameters for created Direct3D device
113 unsigned int myRefreshRate; //!< refresh rate in fullscreen mode
114 bool myIsD3dEx; //!< D3dEx flag for WDDM
115 Handle(D3DHost_FrameBuffer) myD3dWglFbo; //!< D3D/WGL interop FBO
119 DEFINE_STANDARD_RTTIEXT(D3DHost_View,OpenGl_View)
123 DEFINE_STANDARD_HANDLE(D3DHost_View, OpenGl_View)
125 #endif // #ifndef _D3DHost_View_HeaderFile