1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00
xn65/includes/xna/graphics/device.hpp

73 lines
4.0 KiB
C++
Raw Permalink Normal View History

2024-03-18 15:41:46 -03:00
#ifndef XNA_GRAPHICS_DEVICE_HPP
#define XNA_GRAPHICS_DEVICE_HPP
#include "presentparams.hpp"
2024-08-02 16:40:06 -03:00
#include "viewport.hpp"
#include <memory>
2024-03-18 15:41:46 -03:00
namespace xna {
struct GraphicsDeviceImplementation;
2024-06-24 15:11:07 -03:00
//Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders.
2024-11-16 14:21:06 -03:00
class GraphicsDevice : public std::enable_shared_from_this<GraphicsDevice> {
2024-03-18 15:41:46 -03:00
public:
2024-05-24 22:26:10 -03:00
GraphicsDevice();
2024-11-16 14:21:06 -03:00
GraphicsDevice(
std::shared_ptr<GraphicsAdapter> const& adapter,
GraphicsProfile const& graphicsProfile,
std::shared_ptr<PresentationParameters> const& presentationParameters);
2024-06-24 15:11:07 -03:00
//Gets the graphics adapter.
inline std::shared_ptr<GraphicsAdapter> Adapter() const { return adapter; }
2024-06-24 15:11:07 -03:00
//Gets or sets a system-defined instance of a blend state object initialized for alpha blending. The default value is BlendState.Opaque.
inline std::shared_ptr<xna::BlendState> BlendState() const { return blendState; }
2024-06-24 15:11:07 -03:00
//Gets or sets a system-defined instance of a blend state object initialized for alpha blending. The default value is BlendState.Opaque.
void BlendState(std::shared_ptr<xna::BlendState> const& value);
2024-06-24 15:11:07 -03:00
//Gets or sets a system-defined instance of a depth-stencil state object. The default value is DepthStencilState.Default.
inline std::shared_ptr<xna::DepthStencilState> DepthStencilState() const { return depthStencilState; }
2024-06-24 15:11:07 -03:00
//Gets or sets a system-defined instance of a depth-stencil state object. The default value is DepthStencilState.Default.
void DepthStencilState(std::shared_ptr<xna::DepthStencilState> const& value);
2024-06-24 15:11:07 -03:00
//Gets or sets rasterizer state. The default value is RasterizerState.CullCounterClockwise.
inline std::shared_ptr<xna::RasterizerState> RasterizerState() const { return rasterizerState; }
2024-06-24 15:11:07 -03:00
//Gets or sets rasterizer state. The default value is RasterizerState.CullCounterClockwise.
void RasterizerState(std::shared_ptr<xna::RasterizerState> const& value);
2024-06-24 15:11:07 -03:00
//Retrieves a collection of SamplerState objects for the current GraphicsDevice.
inline std::shared_ptr<SamplerStateCollection> SamplerStates() const { return samplerStateCollection; }
2024-08-02 16:40:06 -03:00
//Gets the graphics profile.
constexpr GraphicsProfile Profile() const { return graphicsProfile; }
//Gets the presentation parameters associated with this graphics device.
std::shared_ptr<PresentationParameters> PresentParameters() const { return presentationParameters; }
2024-08-02 16:40:06 -03:00
//Clears resource buffers.
void Clear(Color const& color) const;
2024-08-02 16:40:06 -03:00
//Clears resource buffers.
2024-11-16 14:21:06 -03:00
void Clear(ClearOptions options, Color const& color, float depth, Int stencil) const;
2024-08-02 16:40:06 -03:00
//Presents the display with the contents of the next buffer in the sequence of back buffers owned by the GraphicsDevice.
2024-11-16 14:21:06 -03:00
bool Present() const;
2024-08-02 16:40:06 -03:00
//Resets the presentation parameters for the current GraphicsDevice.
void Reset(std::shared_ptr<PresentationParameters> const& presentationParameters, std::shared_ptr<GraphicsAdapter> const& graphicsAdapter);
2024-08-02 16:40:06 -03:00
//Gets or sets a viewport identifying the portion of the render target to receive draw calls.
constexpr xna::Viewport Viewport() const { return viewport; }
//Gets or sets a viewport identifying the portion of the render target to receive draw calls.
2024-05-24 22:26:10 -03:00
void Viewport(xna::Viewport const& viewport);
//Sets a new render target for this GraphicsDevice.
void SetRenderTarget(std::shared_ptr<RenderTarget2D> const& renderTarget) { this->renderTarget = renderTarget; }
2024-08-02 16:40:06 -03:00
void Initialize();
2024-05-24 22:26:10 -03:00
2024-11-16 14:21:06 -03:00
std::unique_ptr<GraphicsDeviceImplementation> Implementation;
2024-08-02 16:40:06 -03:00
private:
std::shared_ptr<GraphicsAdapter> adapter{ nullptr };
std::shared_ptr<xna::BlendState> blendState{ nullptr };
std::shared_ptr<xna::DepthStencilState> depthStencilState{ nullptr };
std::shared_ptr<xna::RasterizerState> rasterizerState{ nullptr };
std::shared_ptr<SamplerStateCollection> samplerStateCollection{ nullptr };
std::shared_ptr<PresentationParameters> presentationParameters{ nullptr };
std::shared_ptr<RenderTarget2D> renderTarget{ nullptr };
2024-08-02 16:40:06 -03:00
GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef };
2024-11-16 14:21:06 -03:00
xna::Viewport viewport{};
2024-03-18 15:41:46 -03:00
};
}
#endif