#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_RASTERIZER_H #define NUCLEX_GRAPHICS_RASTERIZATION_RASTERIZER_H #include "../Config.h" #include "Topology.h" #include "Viewport.h" #include namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // class RenderTarget2; class GenericVertexBuffer; class GenericIndexBuffer; class VertexShader; class PixelShader; class RasterizerResources; class RasterizerSettings; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization namespace Nuclex { namespace Graphics { namespace Rasterization { // ------------------------------------------------------------------------------------------- // /// Turns polygon-based scene descriptions into pixel bitmaps /// /// Rasterizers must be accessed by only one thread at a time. /// class Rasterizer { /// Initializes a new rasterizer protected: NUCLEX_GRAPHICS_API Rasterizer() {} /// Frees all resources owned by the rasterizer public: NUCLEX_GRAPHICS_API virtual ~Rasterizer() {} /// Accesses the settings management interface of the rasterizer /// The rasterizer's settings management public: virtual const RasterizerSettings &Settings() const = 0; /// Accesses the settings management interface of the rasterizer /// The rasterizer's settings management public: virtual RasterizerSettings &Settings() = 0; /// Accesses the resource management interface of the rasterizer /// The rasterizer's resource management public: virtual const RasterizerResources &Resources() const = 0; /// Accesses the resource management interface of the rasterizer /// The rasterizer's resource management public: virtual RasterizerResources &Resources() = 0; /// Counts the number of vertex streams usable by the rasterizer /// The number of vertex streams the rasterizer can access public: virtual std::size_t CountAvailableVertexStreams() const = 0; /// 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: virtual const std::shared_ptr &GetVertexBuffer( std::size_t index ) const = 0; /// 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: virtual void SetVertexBuffer( std::size_t index, const std::shared_ptr &vertexBuffer ) = 0; /// Returns the index buffer currently bound /// The index buffer currently bound public: virtual const std::shared_ptr &GetIndexBuffer() const = 0; /// Binds the index buffer that defines the vertex order /// Index buffer that will be bound public: virtual void SetIndexBuffer( const std::shared_ptr &indexBuffer ) = 0; /// /// Retrieves the vertex shader the rasterizer is using to transform vertices /// /// The vertex shader that the rasterizer is using public: virtual const std::shared_ptr &GetVertexShader() const = 0; /// Assigns the vertex shader that will be used to transform vertices /// Vertex shader the rasterizer will use public: virtual void SetVertexShader( const std::shared_ptr &vertexShader ) = 0; /// /// Retrieves the pixel shader the rasterizer is using to determine pixel colors /// /// The pixel shader that the rasterizer is using public: virtual const std::shared_ptr &GetPixelShader() const = 0; /// Assigns the pixel shader that will be used to determine pixel colors /// Pixel shader the rasterizer will use public: virtual void SetPixelShader(const std::shared_ptr &pixelShader) = 0; /// Retrieves the render target for the primary rendering surface /// The render target representing the primary rendering surface public: virtual const std::shared_ptr &GetDefaultRenderTarget() = 0; /// Retrieves the current render target /// The current render target of the rasterizer public: virtual const std::shared_ptr &GetRenderTarget() = 0; /// Selects the render target onto which the rasterize will draw /// New render target to draw on public: virtual void SetRenderTarget( const std::shared_ptr &renderTarget ) = 0; /// Returns the currently configured vertex topology /// The topology currently used to connect vertices public: virtual Topology::Enum GetTopology() const = 0; /// Changes the configured vertex topology /// The topology to be used for connecting vertices public: virtual void SetTopology(Topology::Enum topology) = 0; /// Retrieves the current viewport the rasterizer renders to /// The rasterizer's current viewport /// /// Do not use this method if you want to know the screen resolution or window size /// you're rendering to. If you never call SetViewport() it will be identical, but /// as soon as you call SetViewport() once it will stop updating. To determine the /// resolution, call GetDefaultRenderTarget() and query its width and height! /// public: virtual const Viewport &GetViewport() const = 0; /// Sets the viewport the rasterizer will render to /// Viewport the rasterizer will render to /// /// If you never call this method, the rasterizer will assume that you are fine /// with the default viewport which encompasses the entire screen and will update /// the viewport accordingly. The moment you call this method, the rasterizer will /// leave the viewport alone and it is up to you to update it if the screen /// resolution or window size changes! /// public: virtual void SetViewport(const Viewport &viewport) = 0; /// 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: virtual void Rasterize( std::size_t vertexBufferStartIndex = 0, std::size_t vertexCount = static_cast(-1) ) = 0; /// /// 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: virtual 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) ) = 0; /// Presents the rasterized image in the view public: virtual void Present() = 0; private: Rasterizer(const Rasterizer &); private: Rasterizer &operator =(const Rasterizer &); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Graphics::Rasterization #endif // NUCLEX_GRAPHICS_RASTERIZATION_RASTERIZER_H