0026734: Visualization, D3DHost_View - drop outdated UserDraw interfaces
[occt.git] / src / D3DHost / D3DHost_View.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
c357e426 16#ifndef _D3DHost_View_HeaderFile
17#define _D3DHost_View_HeaderFile
62e1beed 18
19#include <d3d9.h>
20
62e1beed 21#include <D3DHost_FrameBuffer.hxx>
c357e426 22#include <OpenGl_View.hxx>
23#include <OpenGl_Workspace.hxx>
24
25class D3DHost_GraphicDriver;
62e1beed 26
c357e426 27//! The D3D host view implementation that overrides rendering methods.
28class D3DHost_View : public OpenGl_View
62e1beed 29{
30
31public:
32
c357e426 33 //! Constructor.
34 Standard_EXPORT D3DHost_View (const Handle(Graphic3d_StructureManager)& theMgr,
35 const Handle(D3DHost_GraphicDriver)& theDriver,
36 const Handle(OpenGl_Caps)& theCaps,
37 Standard_Boolean& theDeviceLostFlag,
38 OpenGl_StateCounter* theCounter);
39
40 //! Default destructor.
41 Standard_EXPORT virtual ~D3DHost_View();
42
43 //! Creates and maps rendering window to the view.
44 //! @param theWindow [in] the window.
45 //! @param theContext [in] the rendering context. If NULL the context will be created internally.
46 //! @param theDisplayCB [in] the display callback function. If is not a NULL value, then the callback will be
47 //! invoked at the end of the OCC graphic traversal and just before the swap of buffers.
48 //! @param theClientData [in] the client data for the callback.
7aa74f30 49 Standard_EXPORT virtual void SetWindow (const Handle(Aspect_Window)& theWindow,
50 const Aspect_RenderingContext theContext) Standard_OVERRIDE;
62e1beed 51
52 //! Resizes the window.
c357e426 53 Standard_EXPORT virtual void Resized() Standard_OVERRIDE;
62e1beed 54
55 //! Redraw the all content.
c357e426 56 Standard_EXPORT virtual void Redraw() Standard_OVERRIDE;
62e1beed 57
58 //! Redraw only immediate layer.
c357e426 59 Standard_EXPORT virtual void RedrawImmediate() Standard_OVERRIDE;
62e1beed 60
61public:
62
63 //! @return true if IDirect3DDevice9Ex device has been created
64 bool isD3dEx() const { return myIsD3dEx; }
65
66 //! Access Direct3D device instance.
67 IDirect3DDevice9* D3dDevice() const { return myD3dDevice; }
68
69 //! Return D3D/WGL FBO.
70 const Handle(D3DHost_FrameBuffer)& D3dWglBuffer() const { return myD3dWglFbo; }
71
c357e426 72 //! Return D3D surface.
73 IDirect3DSurface9* D3dColorSurface() const { return myD3dWglFbo->D3dColorSurface(); }
74
62e1beed 75protected:
76
77 //! Auxiliary method.
78 Standard_EXPORT static TCollection_AsciiString d3dFormatError (HRESULT theErrCode);
79
80 //! Initialize the D3D library.
81 Standard_EXPORT bool d3dInitLib();
82
83 //! Initialize Direct3D output device.
c357e426 84 Standard_EXPORT bool d3dInit();
62e1beed 85
86 //! Reset Direct3D output settings. Could be used to switch windowed/fullscreen modes.
87 //! Use very carefully! Most objects should be released before and recreated after!
c357e426 88 Standard_EXPORT bool d3dReset();
62e1beed 89
90 //! (Re-)create D3D surface.
91 Standard_EXPORT bool d3dCreateRenderTarget();
92
93 //! Starts the scene render.
94 //! Clears the backbuffer and sets the device to start rendering to it.
95 Standard_EXPORT void d3dBeginRender();
96
97 //! Ends the scene render.
98 Standard_EXPORT void d3dEndRender();
99
100 //! Presents to the screen.
101 Standard_EXPORT bool d3dSwap();
102
103protected:
104
105 IDirect3D9* myD3dLib; //!< Direct3D library instance
106 IDirect3DDevice9* myD3dDevice; //!< Direct3D device object
107 D3DPRESENT_PARAMETERS myD3dParams; //!< parameters for created Direct3D device
108 D3DDISPLAYMODE myCurrMode; //!< temporary variable
109 UINT myRefreshRate; //!< refresh rate in fullscreen mode
110 bool myIsD3dEx; //!< D3dEx flag for WDDM
111 Handle(D3DHost_FrameBuffer) myD3dWglFbo; //!< D3D/WGL interop FBO
112
113public:
114
c357e426 115 DEFINE_STANDARD_RTTI(D3DHost_View, OpenGl_View)
62e1beed 116
117};
118
c357e426 119DEFINE_STANDARD_HANDLE(D3DHost_View, OpenGl_View)
62e1beed 120
c357e426 121#endif // #ifndef _D3DHost_View_HeaderFile