18 #ifndef __H__OCULAR_D3D11_GRAPHICS_DRIVER__H__
19 #define __H__OCULAR_D3D11_GRAPHICS_DRIVER__H__
21 #define OCULAR_D3D_11_0 100
22 #define OCULAR_D3D_11_1 200
23 #define OCULAR_D3D_11_2 300
25 #if OCULAR_D3D_11_VERSION > 200
26 #define OCULAR_D3D_USE_11_2
27 #elif OCULAR_D3D11_VERSION > 100
28 #define OCULAR_D3D_USE_11_1
30 #define OCULAR_D3D_USE_11_0
35 #include "Graphics/GraphicsDriver.hpp"
36 #include "Events/AEventListener.hpp"
38 #if defined(OCULAR_D3D_USE_11_0)
40 #elif defined(OCULAR_D3D_USE_11_1)
42 #elif defined(OCULAR_D3D_USE_11_2)
46 #if defined(OCULAR_D3D_USE_11_0)
47 using OD3D11Device = ID3D11Device;
48 using OD3D11DeviceContext = ID3D11DeviceContext;
49 using OD3DSwapChain = IDXGISwapChain;
50 #elif defined(OCULAR_D3D_USE_11_1)
51 using OD3D11Device = ID3D11Device1;
52 using OD3D11DeviceContext = ID3D11DeviceContext1;
53 using OD3DSwapChain = IDXGISwapChain1;
54 #elif defined(OCULAR_D3D_USE_11_2)
55 using OD3D11Device = ID3D11Device2;
56 using OD3D11DeviceContext = ID3D11DeviceContext2;
57 using OD3DSwapChain = IDXGISwapChain1;
104 virtual Viewport* createViewport(
float x,
float y,
float width,
float height,
float minDepth = 0.0f,
float maxDepth = 1.0f)
const override;
123 virtual bool renderMesh(
Mesh* mesh, uint32_t submesh = 0)
override;
129 OD3D11Device* getD3DDevice()
const;
130 OD3D11DeviceContext* getD3DDeviceContext()
const;
131 OD3DSwapChain* getD3DSwapChain()
const;
133 static bool ConvertTextureDescriptor(
TextureDescriptor const& source, D3D11_TEXTURE2D_DESC& dest);
134 static bool ConvertTextureDescriptor(D3D11_TEXTURE2D_DESC
const& source,
TextureDescriptor& dest);
138 virtual bool onEvent(std::shared_ptr<Core::AEvent> event)
override;
139 void resizeSwapChain(uint32_t width, uint32_t height);
141 bool validateWindow(std::shared_ptr<Core::AWindow> window, HWND& hwnd)
const;
142 bool createDeviceAndSwapChain(Core::WindowWin32
const* window, HWND
const hwnd);
144 #if defined(OCULAR_D3D_USE_11_0)
145 DXGI_SWAP_CHAIN_DESC createSwapChainDescription(Core::WindowWin32
const* window)
const;
147 DXGI_SWAP_CHAIN_DESC1 createSwapChainDescription(Core::WindowWin32
const* window)
const;
150 bool fetchDeviceAndSwapChain1(ID3D11Device* device, ID3D11DeviceContext* context, Core::WindowWin32
const* window);
151 bool fetchDeviceAndSwapChain2(ID3D11Device* device, ID3D11DeviceContext* context, Core::WindowWin32
const* window);
155 void printD3DDebug();
159 OD3D11Device* m_D3DDevice;
160 OD3D11DeviceContext* m_D3DDeviceContext;
161 OD3DSwapChain* m_D3DSwapChain;
Definition: VertexBuffer.hpp:78
virtual void clearDepthBuffer(float value=1.0f) override
Definition: D3D11GraphicsDriver.cpp:214
virtual void setRenderTexture(RenderTexture *texture) override
Definition: D3D11GraphicsDriver.cpp:292
Definition: Texture2D.hpp:45
static bool ValidateTextureDescriptor(TextureDescriptor const &descriptor)
Definition: D3D11GraphicsDriver.cpp:1448
Definition: FragmentShader.hpp:40
Definition: VertexShader.hpp:40
virtual GPUBuffer * createGPUBuffer(GPUBufferDescriptor const &descriptor) const override
Definition: D3D11GraphicsDriver.cpp:487
virtual IndexBuffer * createIndexBuffer() const override
Definition: D3D11GraphicsDriver.cpp:477
A special texture that stores high precision depth information for each pixel.
Definition: DepthTexture.hpp:41
A special texture that can be rendered directly to.
Definition: RenderTexture.hpp:41
virtual Texture * createTexture(TextureDescriptor const &descriptor) const override
Definition: D3D11GraphicsDriver.cpp:360
Definition: D3D11GraphicsDriver.hpp:83
Definition: AEventListener.hpp:43
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70
Definition: PreTessellationShader.hpp:40
virtual Material * createMaterial() const override
Definition: D3D11GraphicsDriver.cpp:346
virtual bool renderBounds(Core::SceneObject *object, Math::BoundsType type) override
Definition: D3D11GraphicsDriver.cpp:530
Combination of a VertexBuffer and IndexBuffer.
Definition: Mesh.hpp:49
Definition: TextureDescriptor.hpp:45
virtual RenderTexture * createRenderTexture(TextureDescriptor const &descriptor) const override
Definition: D3D11GraphicsDriver.cpp:402
static Color const & DefaultClearGray()
Definition: Color.cpp:173
A generic buffer that can be uploaded to the GPU.
Definition: GPUBuffer.hpp:81
virtual void swapBuffers() override
Definition: D3D11GraphicsDriver.cpp:260
virtual VertexBuffer * createVertexBuffer() const override
Definition: D3D11GraphicsDriver.cpp:482
Definition: SceneObject.hpp:93
virtual DepthTexture * createDepthTexture(TextureDescriptor const &descriptor) const override
Definition: D3D11GraphicsDriver.cpp:418
Definition: GPUBuffer.hpp:62
virtual VertexShader * createVertexShader() const override
Definition: D3D11GraphicsDriver.cpp:443
virtual UniformBuffer * createUniformBuffer(UniformBufferType type) const override
Definition: D3D11GraphicsDriver.cpp:472
virtual Texture2D * createTexture2D(TextureDescriptor const &descriptor) const override
Definition: D3D11GraphicsDriver.cpp:386
virtual PostTessellationShader * createPostTessellationShader() const override
Definition: D3D11GraphicsDriver.cpp:463
virtual FragmentShader * createFragmentShader() const override
Definition: D3D11GraphicsDriver.cpp:453
Definition: IndexBuffer.hpp:77
Definition: PostTessellationShader.hpp:40
virtual uint32_t getMaxBoundTextures() const override
Definition: D3D11GraphicsDriver.cpp:434
Definition: Viewport.hpp:40
virtual PreTessellationShader * createPreTessellationShader() const override
Definition: D3D11GraphicsDriver.cpp:458
virtual void clearBuffers(Core::Color const &clearColor=Core::Color::DefaultClearGray()) override
Definition: D3D11GraphicsDriver.cpp:182
virtual GeometryShader * createGeometryShader() const override
Definition: D3D11GraphicsDriver.cpp:448
virtual bool renderMesh(Mesh *mesh, uint32_t submesh=0) override
Definition: D3D11GraphicsDriver.cpp:503
virtual void setDepthTexture(DepthTexture *texture) override
Definition: D3D11GraphicsDriver.cpp:319
virtual void clearStencilBuffer(uint32_t value=0) override
Definition: D3D11GraphicsDriver.cpp:237
virtual bool initialize() override
Definition: D3D11GraphicsDriver.cpp:99
Definition: GeometryShader.hpp:40
Definition: Material.hpp:62
Base class for all texture objects.
Definition: Texture.hpp:45
Definition: GraphicsDriver.hpp:59