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

72 lines
3.7 KiB
C++
Raw Normal View History

2024-03-18 15:41:46 -03:00
#ifndef XNA_GRAPHICS_DEVICE_HPP
#define XNA_GRAPHICS_DEVICE_HPP
2024-05-24 22:26:10 -03:00
#include "../default.hpp"
#include "presentparams.hpp"
2024-08-02 16:40:06 -03:00
#include "viewport.hpp"
2024-03-18 15:41:46 -03:00
namespace xna {
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-05-24 22:26:10 -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-08-02 16:40:06 -03:00
GraphicsDevice(P_GraphicsAdapter const& adapter, GraphicsProfile const& graphicsProfile, P_PresentationParameters const& presentationParameters);
2024-06-24 15:11:07 -03:00
//Gets the graphics adapter.
2024-08-02 16:40:06 -03:00
inline P_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.
2024-08-02 16:40:06 -03:00
inline P_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.
2024-08-02 16:40:06 -03:00
void BlendState(P_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.
2024-08-02 16:40:06 -03:00
inline P_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.
2024-08-02 16:40:06 -03:00
void DepthStencilState(P_DepthStencilState const& value);
2024-06-24 15:11:07 -03:00
//Gets or sets rasterizer state. The default value is RasterizerState.CullCounterClockwise.
2024-08-02 16:40:06 -03:00
inline P_RasterizerState RasterizerState() const { return rasterizerState; }
2024-06-24 15:11:07 -03:00
//Gets or sets rasterizer state. The default value is RasterizerState.CullCounterClockwise.
2024-08-02 16:40:06 -03:00
void RasterizerState(P_RasterizerState const& value);
2024-06-24 15:11:07 -03:00
//Retrieves a collection of SamplerState objects for the current GraphicsDevice.
2024-08-02 16:40:06 -03:00
inline P_SamplerStateCollection SamplerStates() const { return samplerStateCollection; }
//Gets the graphics profile.
constexpr GraphicsProfile Profile() const { return graphicsProfile; }
//Gets the presentation parameters associated with this graphics device.
P_PresentationParameters PresentParameters() const { return presentationParameters; }
//Clears resource buffers.
void Clear(Color const& color) const;
2024-08-02 16:40:06 -03:00
//Clears resource buffers.
void Clear(ClearOptions options, Color const& color, float depth, Int stencil) const;
//Presents the display with the contents of the next buffer in the sequence of back buffers owned by the GraphicsDevice.
bool Present() const;
//Resets the presentation parameters for the current GraphicsDevice.
void Reset(P_PresentationParameters const& presentationParameters, P_GraphicsAdapter const& graphicsAdapter);
//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(P_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-08-02 16:40:06 -03:00
private:
P_GraphicsAdapter adapter{ nullptr };
P_BlendState blendState{ nullptr };
P_DepthStencilState depthStencilState{ nullptr };
P_RasterizerState rasterizerState{ nullptr };
P_SamplerStateCollection samplerStateCollection{ nullptr };
P_PresentationParameters presentationParameters{ nullptr };
P_RenderTarget2D renderTarget{ nullptr };
2024-08-02 16:40:06 -03:00
GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef };
xna::Viewport viewport{};
2024-06-05 21:09:35 -03:00
2024-05-24 22:26:10 -03:00
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl = nullptr;
2024-03-18 15:41:46 -03:00
};
2024-06-09 20:18:13 -03:00
using PGraphicsDevice = sptr<GraphicsDevice>;
2024-03-18 15:41:46 -03:00
}
#endif