#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11RASTERIZER_H #define NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11RASTERIZER_H #include "../Config.h" #include "Rasterizer.h" #if defined(NUCLEX_GRAPHICS_WINRT) #include #elif defined(NUCLEX_GRAPHICS_WIN32) #define WIN32_LEAN_AND_MEAN #define VC_EXTRALEAN #define NO_MINMAX #include #endif namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // ///Uses Direct3D 11 to render polygon-based scenes class Direct3D11Rasterizer : public Rasterizer { #if defined(NUCLEX_GRAPHICS_WINRT) /// Initializes a new Direct3D 11 polygon renderer /// Window into which to render public: NUCLEX_GRAPHICS_API Direct3D11Rasterizer(Windows::UI::Core::CoreWindow ^window); #elif defined(NUCLEX_GRAPHICS_WIN32) /// Initializes a new Direct3D 11 polygon renderer /// Handle of the window into which to render public: NUCLEX_GRAPHICS_API Direct3D11Rasterizer(HWND windowHandle); #endif /// Frees all resources owned by the rasterizer public: NUCLEX_GRAPHICS_API virtual ~Direct3D11Rasterizer(); /// Checks whether Direct3D 11 is available on the system /// True if Direct3D 11 is available public: NUCLEX_GRAPHICS_API static bool IsAvailable(); /// Accesses the settings management interface of the rasterizer /// The rasterizer's settings management public: NUCLEX_GRAPHICS_API const RasterizerSettings &Settings() const; /// Accesses the settings management interface of the rasterizer /// The rasterizer's settings management public: NUCLEX_GRAPHICS_API RasterizerSettings &Settings(); /// Accesses the resource management interface of the rasterizer /// The rasterizer's resource management public: NUCLEX_GRAPHICS_API const RasterizerResources &Resources() const; /// Accesses the resource management interface of the rasterizer /// The rasterizer's resource management public: NUCLEX_GRAPHICS_API RasterizerResources &Resources(); /// Counts the number of vertex streams usable by the rasterizer /// The number of vertex streams the rasterizer can access public: NUCLEX_GRAPHICS_API std::size_t CountAvailableVertexStreams() const; /// Returns the vertex buffer currently bound to the specified stream /// Index of the stream whose bound vertex buffer is returned /// The vertex buffer bound to the specified stream public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetVertexBuffer( std::size_t index ) const; /// Binds a vertex buffer to the specified stream /// Index of the stream the vertex buffer will be bound to /// Vertex buffer that will be bound to the stream public: NUCLEX_GRAPHICS_API void SetVertexBuffer( std::size_t index, const std::shared_ptr &vertexBuffer ); /// Returns the index buffer currently bound /// The index buffer currently bound public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetIndexBuffer() const; /// Binds the index buffer that defines the vertex order /// Index buffer that will be bound public: NUCLEX_GRAPHICS_API void SetIndexBuffer( const std::shared_ptr &indexBuffer ); /// /// Retrieves the vertex shader the rasterizer is using to transform vertices /// /// The vertex shader that the rasterizer is using public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetVertexShader() const; /// Assigns the vertex shader that will be used to transform vertices /// Vertex shader the rasterizer will use public: NUCLEX_GRAPHICS_API void SetVertexShader( const std::shared_ptr &vertexShader ); /// /// Retrieves the pixel shader the rasterizer is using to determine pixel colors /// /// The pixel shader that the rasterizer is using public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetPixelShader() const; /// Assigns the pixel shader that will be used to determine pixel colors /// Pixel shader the rasterizer will use public: NUCLEX_GRAPHICS_API void SetPixelShader( const std::shared_ptr &pixelShader ); /// Retrieves the render target for the primary rendering surface /// The render target representing the primary rendering surface public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetDefaultRenderTarget(); /// Retrieves the current render target /// The current render target of the rasterizer public: NUCLEX_GRAPHICS_API const std::shared_ptr &GetRenderTarget(); /// Selects the render target onto which the rasterize will draw /// New render target to draw on public: NUCLEX_GRAPHICS_API void SetRenderTarget( const std::shared_ptr &renderTarget ); /// Returns the currently configured vertex topology /// The topology currently used to connect vertices public: NUCLEX_GRAPHICS_API Topology::Enum GetTopology() const; /// Changes the configured vertex topology /// The topology to be used for connecting vertices public: NUCLEX_GRAPHICS_API void SetTopology(Topology::Enum topology); /// Retrieves the current viewport the rasterizer renders to /// The rasterizer's current viewport public: NUCLEX_GRAPHICS_API const Viewport &GetViewport() const; /// Sets the viewport the rasterizer will render to /// Viewport the rasterizer will render to public: NUCLEX_GRAPHICS_API void SetViewport(const Viewport &viewport); /// Rasterizes primitives using the currently bound vertex buffers /// /// Index in the vertex buffers at which resterization will begin /// /// Number of vertices that will be rasterized public: NUCLEX_GRAPHICS_API void Rasterize( std::size_t vertexBufferStartIndex = 0, std::size_t vertexCount = static_cast(-1) ); /// /// Rasterizes primitives by indexing the bound vertex buffers through /// the bound index buffers /// /// /// Position in the index buffer rasterization will begin at /// /// Number of indices that will used for rasterization /// /// Index of the first vertex that will be accessed by this operation. /// Providing this value can speed up hardware rasterization. /// /// /// Index of the last vertex that will be accessed by this operation (exclusive). /// Providing this value can speed up hardware rasterization. /// public: NUCLEX_GRAPHICS_API void RasterizeIndexed( std::size_t indexBufferStartIndex = 0, std::size_t indexCount = static_cast(-1), std::size_t firstAccessedVertexIndex = 0, std::size_t lastAccessedVertexIndex = static_cast(-1) ); /// Presents the rasterized image in the view public: NUCLEX_GRAPHICS_API void Present(); #if defined(NUCLEX_GRAPHICS_WINRT) /// Stores private implementation details private: ref struct Impl; /// Private implementation details of the rasterizer private: Impl ^impl; #elif defined(NUCLEX_GRAPHICS_WIN32) /// Stores private implementation details private: struct Impl; /// Private implementation details of the rasterizer private: Impl *impl; #endif }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization #endif // NUCLEX_GRAPHICS_RASTERIZATION_DIRECT3D11RASTERIZER_H