mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa recursos gráficos
This commit is contained in:
parent
a7cef87f59
commit
dcf6c06cfb
@ -166,9 +166,9 @@ namespace xna {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum class FillMode
|
enum class FillMode
|
||||||
{
|
{
|
||||||
Solid,
|
|
||||||
WireFrame,
|
WireFrame,
|
||||||
|
Solid,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class GamePadCapabilitiesType
|
enum class GamePadCapabilitiesType
|
||||||
@ -446,8 +446,8 @@ namespace xna {
|
|||||||
|
|
||||||
enum class TextureAddressMode {
|
enum class TextureAddressMode {
|
||||||
Wrap,
|
Wrap,
|
||||||
Clamp,
|
|
||||||
Mirror,
|
Mirror,
|
||||||
|
Clamp,
|
||||||
Border,
|
Border,
|
||||||
MirrorOnce
|
MirrorOnce
|
||||||
};
|
};
|
||||||
|
@ -9,17 +9,12 @@ namespace xna {
|
|||||||
class IBlendState {
|
class IBlendState {
|
||||||
public:
|
public:
|
||||||
virtual ~IBlendState() {}
|
virtual ~IBlendState() {}
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0;
|
virtual bool Initialize(xna_error_nullarg) = 0;
|
||||||
virtual void AlphaToCoverageEnable(bool value) = 0;
|
virtual void AlphaToCoverageEnable(bool value) = 0;
|
||||||
virtual void IndependentBlendEnable(bool value) = 0;
|
virtual void IndependentBlendEnable(bool value) = 0;
|
||||||
virtual void RenderTargets(std::vector<BlendRenderTarget> const& value) = 0;
|
virtual void RenderTargets(std::vector<BlendRenderTarget> const& value) = 0;
|
||||||
|
|
||||||
virtual bool Apply(GraphicsDevice& device, xna_error_nullarg) = 0;
|
virtual bool Apply(xna_error_nullarg) = 0;
|
||||||
|
|
||||||
static PBlendState Opaque();
|
|
||||||
static PBlendState AlphaBlend();
|
|
||||||
static PBlendState Additive();
|
|
||||||
static PBlendState NonPremultiplied();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@ namespace xna {
|
|||||||
class IDepthStencilState {
|
class IDepthStencilState {
|
||||||
public:
|
public:
|
||||||
virtual ~IDepthStencilState(){}
|
virtual ~IDepthStencilState(){}
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0;
|
virtual bool Initialize(xna_error_nullarg) = 0;
|
||||||
virtual bool Apply(GraphicsDevice& device, xna_error_ptr_arg) = 0;
|
virtual bool Apply(xna_error_ptr_arg) = 0;
|
||||||
|
|
||||||
virtual void DepthEnabled(bool value) = 0;
|
virtual void DepthEnabled(bool value) = 0;
|
||||||
virtual void DepthWriteEnabled(bool value) = 0;
|
virtual void DepthWriteEnabled(bool value) = 0;
|
||||||
@ -38,11 +38,7 @@ namespace xna {
|
|||||||
virtual StencilOperation StencilBackFacePass() = 0;
|
virtual StencilOperation StencilBackFacePass() = 0;
|
||||||
virtual StencilOperation StencilBackFaceFail() = 0;
|
virtual StencilOperation StencilBackFaceFail() = 0;
|
||||||
virtual StencilOperation StencilBackFaceDepthFail() = 0;
|
virtual StencilOperation StencilBackFaceDepthFail() = 0;
|
||||||
virtual ComparisonFunction StencilBackFaceCompare() = 0;
|
virtual ComparisonFunction StencilBackFaceCompare() = 0;
|
||||||
|
|
||||||
static PDepthStencilState None();
|
|
||||||
static PDepthStencilState Default();
|
|
||||||
static PDepthStencilState DepthRead();
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,8 @@ namespace xna {
|
|||||||
class IRasterizerState {
|
class IRasterizerState {
|
||||||
public:
|
public:
|
||||||
virtual ~IRasterizerState() {}
|
virtual ~IRasterizerState() {}
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) = 0;
|
virtual bool Initialize(xna_error_nullarg) = 0;
|
||||||
|
virtual bool Apply(xna_error_nullarg) = 0;
|
||||||
virtual xna::CullMode CullMode() const = 0;
|
virtual xna::CullMode CullMode() const = 0;
|
||||||
virtual void CullMode(xna::CullMode value) = 0;
|
virtual void CullMode(xna::CullMode value) = 0;
|
||||||
virtual xna::FillMode FillMode() const = 0;
|
virtual xna::FillMode FillMode() const = 0;
|
||||||
|
@ -7,7 +7,7 @@ namespace xna {
|
|||||||
class IShader {
|
class IShader {
|
||||||
public:
|
public:
|
||||||
virtual ~IShader() {}
|
virtual ~IShader() {}
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_nullarg) = 0;
|
virtual bool Initialize(DataBuffer& buffer, xna_error_nullarg) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ namespace xna {
|
|||||||
class ISwapChain {
|
class ISwapChain {
|
||||||
public:
|
public:
|
||||||
virtual ~ISwapChain() {}
|
virtual ~ISwapChain() {}
|
||||||
virtual bool Initialize(GraphicsDevice& device, GameWindow const& gameWindow) = 0;
|
virtual bool Initialize(GameWindow const& gameWindow, xna_error_nullarg) = 0;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#include "device-dx.hpp"
|
#include "device-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
bool BlendState::Initialize(GraphicsDevice& device, xna_error_ptr_arg)
|
bool BlendState::Initialize(xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!device._device) {
|
if (!m_device || !m_device->_device) {
|
||||||
xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ namespace xna {
|
|||||||
dxBlendState = nullptr;
|
dxBlendState = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hr = device._device->CreateBlendState(&dxDescription, &dxBlendState);
|
const auto hr = m_device->_device->CreateBlendState(&dxDescription, &dxBlendState);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||||
@ -24,24 +24,24 @@ namespace xna {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BlendState::Apply(GraphicsDevice& device, xna_error_ptr_arg) {
|
bool BlendState::Apply(xna_error_ptr_arg) {
|
||||||
if (!device._context) {
|
if (!m_device || !m_device->_context) {
|
||||||
xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dxBlendState) {
|
if (!dxBlendState) {
|
||||||
const auto init = Initialize(device, err);
|
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
||||||
if (!init) return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
device._context->OMSetBlendState(dxBlendState, blendFactor, sampleMask);
|
m_device->_context->OMSetBlendState(dxBlendState, blendFactor, sampleMask);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PBlendState IBlendState::Opaque() {
|
uptr<BlendState> BlendState::Opaque() {
|
||||||
auto blendState = New<BlendState>();
|
auto blendState = std::unique_ptr<BlendState>(new BlendState());
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
||||||
@ -50,8 +50,8 @@ namespace xna {
|
|||||||
return blendState;
|
return blendState;
|
||||||
}
|
}
|
||||||
|
|
||||||
PBlendState IBlendState::AlphaBlend() {
|
uptr<BlendState> BlendState::AlphaBlend() {
|
||||||
auto blendState = New<BlendState>();
|
auto blendState = std::unique_ptr<BlendState>(new BlendState());
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE;
|
||||||
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
@ -60,8 +60,8 @@ namespace xna {
|
|||||||
return blendState;
|
return blendState;
|
||||||
}
|
}
|
||||||
|
|
||||||
PBlendState IBlendState::Additive() {
|
uptr<BlendState> BlendState::Additive() {
|
||||||
auto blendState = New<BlendState>();
|
auto blendState = std::unique_ptr<BlendState>(new BlendState());
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
||||||
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
|
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_ONE;
|
||||||
@ -70,8 +70,8 @@ namespace xna {
|
|||||||
return blendState;
|
return blendState;
|
||||||
}
|
}
|
||||||
|
|
||||||
PBlendState IBlendState::NonPremultiplied() {
|
uptr<BlendState> BlendState::NonPremultiplied() {
|
||||||
auto blendState = New<BlendState>();
|
auto blendState = std::unique_ptr<BlendState>(new BlendState());
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||||
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
||||||
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
blendState->dxDescription.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#define XNA_PLATFORM_BLENDSTATE_HPP
|
#define XNA_PLATFORM_BLENDSTATE_HPP
|
||||||
|
|
||||||
#include "../graphics/blendstate.hpp"
|
#include "../graphics/blendstate.hpp"
|
||||||
|
#include "../graphics/gresource.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
@ -18,9 +19,9 @@ namespace xna {
|
|||||||
constexpr BlendRenderTarget() = default;
|
constexpr BlendRenderTarget() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BlendState : public IBlendState {
|
class BlendState : public IBlendState, public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
BlendState() = default;
|
BlendState(GraphicsDevice* device) : GraphicsResource(device) {};
|
||||||
|
|
||||||
virtual ~BlendState() override {
|
virtual ~BlendState() override {
|
||||||
if (dxBlendState) {
|
if (dxBlendState) {
|
||||||
@ -28,7 +29,7 @@ namespace xna {
|
|||||||
dxBlendState = nullptr;
|
dxBlendState = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override;
|
virtual bool Initialize(xna_error_nullarg) override;
|
||||||
|
|
||||||
virtual constexpr void AlphaToCoverageEnable(bool value) override {
|
virtual constexpr void AlphaToCoverageEnable(bool value) override {
|
||||||
dxDescription.AlphaToCoverageEnable = value;
|
dxDescription.AlphaToCoverageEnable = value;
|
||||||
@ -51,13 +52,21 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Apply(GraphicsDevice& device, xna_error_nullarg) override;
|
virtual bool Apply(xna_error_nullarg) override;
|
||||||
|
|
||||||
|
static uptr<BlendState> Opaque();
|
||||||
|
static uptr<BlendState> AlphaBlend();
|
||||||
|
static uptr<BlendState> Additive();
|
||||||
|
static uptr<BlendState> NonPremultiplied();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ID3D11BlendState* dxBlendState{ nullptr };
|
ID3D11BlendState* dxBlendState{ nullptr };
|
||||||
D3D11_BLEND_DESC dxDescription{};
|
D3D11_BLEND_DESC dxDescription{};
|
||||||
float blendFactor[4] { 1.0F, 1.0F, 1.0F, 1.0F };
|
float blendFactor[4] { 1.0F, 1.0F, 1.0F, 1.0F };
|
||||||
UINT sampleMask{ 0xffffffff };
|
UINT sampleMask{ 0xffffffff };
|
||||||
|
|
||||||
|
private:
|
||||||
|
BlendState() : GraphicsResource(nullptr){}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
||||||
|
@ -2,19 +2,19 @@
|
|||||||
#include "device-dx.hpp"
|
#include "device-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
bool DepthStencilState::Initialize(GraphicsDevice& device, xna_error_ptr_arg)
|
bool DepthStencilState::Initialize(xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!device._device) {
|
if (!m_device || !m_device->_device) {
|
||||||
xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_depthStencil) {
|
if (dxDepthStencil) {
|
||||||
_depthStencil->Release();
|
dxDepthStencil->Release();
|
||||||
_depthStencil = nullptr;
|
dxDepthStencil = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hr = device._device->CreateDepthStencilState(&_description, &_depthStencil);
|
const auto hr = m_device->_device->CreateDepthStencilState(&dxDescription, &dxDepthStencil);
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||||
@ -24,43 +24,43 @@ namespace xna {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DepthStencilState::Apply(GraphicsDevice& device, xna_error_ptr_arg)
|
bool DepthStencilState::Apply(xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!device._context) {
|
if (!m_device || !m_device->_context) {
|
||||||
xna_error_apply(err, XnaErrorCode::ARGUMENT_IS_NULL);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_depthStencil) {
|
if (!dxDepthStencil) {
|
||||||
const auto init = Initialize(device, err);
|
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
||||||
if (!init) return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
device._context->OMSetDepthStencilState(_depthStencil, 0);
|
m_device->_context->OMSetDepthStencilState(dxDepthStencil, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDepthStencilState IDepthStencilState::None() {
|
uptr<DepthStencilState> DepthStencilState::None() {
|
||||||
auto stencil = New<DepthStencilState>();
|
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
||||||
stencil->_description.DepthEnable = false;
|
stencil->dxDescription.DepthEnable = false;
|
||||||
stencil->_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDepthStencilState IDepthStencilState::Default() {
|
uptr<DepthStencilState> DepthStencilState::Default() {
|
||||||
auto stencil = New<DepthStencilState>();
|
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
||||||
stencil->_description.DepthEnable = true;
|
stencil->dxDescription.DepthEnable = true;
|
||||||
stencil->_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDepthStencilState IDepthStencilState::DepthRead() {
|
uptr<DepthStencilState> DepthStencilState::DepthRead() {
|
||||||
auto stencil = New<DepthStencilState>();
|
auto stencil = std::unique_ptr<DepthStencilState>(new DepthStencilState());
|
||||||
stencil->_description.DepthEnable = true;
|
stencil->dxDescription.DepthEnable = true;
|
||||||
stencil->_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
stencil->dxDescription.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
|
|
||||||
return stencil;
|
return stencil;
|
||||||
}
|
}
|
||||||
|
@ -2,16 +2,175 @@
|
|||||||
#define XNA_PLATFORM_DEPTHSTENCILSTATE_DX_HPP
|
#define XNA_PLATFORM_DEPTHSTENCILSTATE_DX_HPP
|
||||||
|
|
||||||
#include "../graphics/depthstencilstate.hpp"
|
#include "../graphics/depthstencilstate.hpp"
|
||||||
|
#include "../graphics/gresource.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class DepthStencilState : public IDepthStencilState {
|
class DepthStencilState : public IDepthStencilState, public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
DepthStencilState() {
|
DepthStencilState(GraphicsDevice* device) : GraphicsResource(device) {
|
||||||
|
dxDescription = defaultDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~DepthStencilState() override {
|
||||||
|
if (dxDepthStencil) {
|
||||||
|
dxDepthStencil->Release();
|
||||||
|
dxDepthStencil = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Initialize(xna_error_nullarg) override;
|
||||||
|
virtual bool Apply(xna_error_ptr_arg) override;
|
||||||
|
|
||||||
|
virtual constexpr void DepthEnabled(bool value) override {
|
||||||
|
dxDescription.DepthEnable = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void DepthWriteEnabled(bool value) override {
|
||||||
|
dxDescription.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void DepthCompareFunction(ComparisonFunction value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilEnabled(bool value) override {
|
||||||
|
dxDescription.StencilEnable = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilReadMask(int value) override {
|
||||||
|
dxDescription.StencilReadMask = static_cast<UINT8>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilWriteMask(int value) override {
|
||||||
|
dxDescription.StencilWriteMask = static_cast<UINT8>(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilFrontFacePass(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilFrontFaceFail(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilFrontFaceDepthFail(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilFrontFaceCompare(ComparisonFunction value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilBackFacePass(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilBackFaceFail(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilBackFaceDepthFail(StencilOperation value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr void StencilBackFaceCompare(ComparisonFunction value) override {
|
||||||
|
const auto _value = static_cast<int>(value) + 1;
|
||||||
|
dxDescription.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr bool DepthEnabled() override {
|
||||||
|
return dxDescription.DepthEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr bool DepthWriteEnabled() override {
|
||||||
|
return static_cast<bool>(dxDescription.DepthWriteMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr ComparisonFunction DepthCompareFunction() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.DepthFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr bool StencilEnabled() override {
|
||||||
|
return dxDescription.StencilEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr int StencilReadMask() override {
|
||||||
|
return static_cast<int>(dxDescription.StencilReadMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr int StencilWriteMask() override {
|
||||||
|
return static_cast<int>(dxDescription.StencilWriteMask);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilFrontFacePass() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilPassOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilFrontFaceFail() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilFrontFaceDepthFail() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilDepthFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr ComparisonFunction StencilFrontFaceCompare() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.FrontFace.StencilFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilBackFacePass() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.BackFace.StencilPassOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilBackFaceFail() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.BackFace.StencilFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr StencilOperation StencilBackFaceDepthFail() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.BackFace.StencilDepthFailOp) - 1;
|
||||||
|
return static_cast<StencilOperation>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual constexpr ComparisonFunction StencilBackFaceCompare() override {
|
||||||
|
const auto _value = static_cast<int>(dxDescription.BackFace.StencilFunc) - 1;
|
||||||
|
return static_cast<ComparisonFunction>(_value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uptr<DepthStencilState> None();
|
||||||
|
static uptr<DepthStencilState> Default();
|
||||||
|
static uptr<DepthStencilState> DepthRead();
|
||||||
|
|
||||||
|
public:
|
||||||
|
ID3D11DepthStencilState* dxDepthStencil = nullptr;
|
||||||
|
D3D11_DEPTH_STENCIL_DESC dxDescription{};
|
||||||
|
|
||||||
|
private:
|
||||||
|
DepthStencilState() : GraphicsResource(nullptr) {
|
||||||
|
dxDescription = defaultDesc();
|
||||||
|
}
|
||||||
|
|
||||||
|
static D3D11_DEPTH_STENCIL_DESC defaultDesc() {
|
||||||
|
D3D11_DEPTH_STENCIL_DESC _description{};
|
||||||
_description.DepthEnable = true;
|
_description.DepthEnable = true;
|
||||||
_description.StencilEnable = true;
|
_description.StencilEnable = true;
|
||||||
_description.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
|
_description.DepthFunc = D3D11_COMPARISON_LESS_EQUAL;
|
||||||
|
|
||||||
_description.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
_description.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;
|
||||||
_description.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
_description.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
|
||||||
_description.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
_description.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
|
||||||
@ -25,151 +184,9 @@ namespace xna {
|
|||||||
_description.StencilReadMask = 0;
|
_description.StencilReadMask = 0;
|
||||||
_description.StencilWriteMask = 0;
|
_description.StencilWriteMask = 0;
|
||||||
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
_description.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~DepthStencilState() override {
|
return _description;
|
||||||
if (_depthStencil) {
|
|
||||||
_depthStencil->Release();
|
|
||||||
_depthStencil = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override;
|
|
||||||
virtual bool Apply(GraphicsDevice& device, xna_error_ptr_arg) override;
|
|
||||||
|
|
||||||
virtual constexpr void DepthEnabled(bool value) override {
|
|
||||||
_description.DepthEnable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void DepthWriteEnabled(bool value) override {
|
|
||||||
_description.DepthWriteMask = static_cast<D3D11_DEPTH_WRITE_MASK>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void DepthCompareFunction(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.DepthFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilEnabled(bool value) override {
|
|
||||||
_description.StencilEnable = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilReadMask(int value) override {
|
|
||||||
_description.StencilReadMask = static_cast<UINT8>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilWriteMask(int value) override {
|
|
||||||
_description.StencilWriteMask = static_cast<UINT8>(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFacePass(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.FrontFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.FrontFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceDepthFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.FrontFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilFrontFaceCompare(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.FrontFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFacePass(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.BackFace.StencilPassOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.BackFace.StencilFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceDepthFail(StencilOperation value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.BackFace.StencilDepthFailOp = static_cast<D3D11_STENCIL_OP>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr void StencilBackFaceCompare(ComparisonFunction value) override {
|
|
||||||
const auto _value = static_cast<int>(value) + 1;
|
|
||||||
_description.BackFace.StencilFunc = static_cast<D3D11_COMPARISON_FUNC>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool DepthEnabled() override {
|
|
||||||
return _description.DepthEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool DepthWriteEnabled() override {
|
|
||||||
return static_cast<bool>(_description.DepthWriteMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction DepthCompareFunction() override {
|
|
||||||
const auto _value = static_cast<int>(_description.DepthFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr bool StencilEnabled() override {
|
|
||||||
return _description.StencilEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr int StencilReadMask() override {
|
|
||||||
return static_cast<int>(_description.StencilReadMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr int StencilWriteMask() override {
|
|
||||||
return static_cast<int>(_description.StencilWriteMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFacePass() override {
|
|
||||||
const auto _value = static_cast<int>(_description.FrontFace.StencilPassOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFaceFail() override {
|
|
||||||
const auto _value = static_cast<int>(_description.FrontFace.StencilFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilFrontFaceDepthFail() override {
|
|
||||||
const auto _value = static_cast<int>(_description.FrontFace.StencilDepthFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction StencilFrontFaceCompare() override {
|
|
||||||
const auto _value = static_cast<int>(_description.FrontFace.StencilFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFacePass() override {
|
|
||||||
const auto _value = static_cast<int>(_description.BackFace.StencilPassOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFaceFail() override {
|
|
||||||
const auto _value = static_cast<int>(_description.BackFace.StencilFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr StencilOperation StencilBackFaceDepthFail() override {
|
|
||||||
const auto _value = static_cast<int>(_description.BackFace.StencilDepthFailOp) - 1;
|
|
||||||
return static_cast<StencilOperation>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual constexpr ComparisonFunction StencilBackFaceCompare() override {
|
|
||||||
const auto _value = static_cast<int>(_description.BackFace.StencilFunc) - 1;
|
|
||||||
return static_cast<ComparisonFunction>(_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
|
||||||
ID3D11DepthStencilState* _depthStencil = nullptr;
|
|
||||||
D3D11_DEPTH_STENCIL_DESC _description{};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ namespace xna {
|
|||||||
|
|
||||||
if (_blendState == nullptr)
|
if (_blendState == nullptr)
|
||||||
_blendState = BlendState::NonPremultiplied();
|
_blendState = BlendState::NonPremultiplied();
|
||||||
|
_blendState->Bind(this);
|
||||||
|
|
||||||
_createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
_createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||||
|
|
||||||
@ -66,9 +67,9 @@ namespace xna {
|
|||||||
_backgroundColor[3] = 1.0f;
|
_backgroundColor[3] = 1.0f;
|
||||||
|
|
||||||
if (!_swapChain)
|
if (!_swapChain)
|
||||||
_swapChain = New<xna::SwapChain>();
|
_swapChain = New<xna::SwapChain>(this);
|
||||||
|
|
||||||
_swapChain->Initialize(*this, gameWindow);
|
_swapChain->Initialize(gameWindow);
|
||||||
|
|
||||||
if FAILED(_factory->MakeWindowAssociation(gameWindow.WindowHandle(), DXGI_MWA_NO_ALT_ENTER))
|
if FAILED(_factory->MakeWindowAssociation(gameWindow.WindowHandle(), DXGI_MWA_NO_ALT_ENTER))
|
||||||
return false;
|
return false;
|
||||||
@ -92,7 +93,7 @@ namespace xna {
|
|||||||
|
|
||||||
_context->RSSetViewports(1, &view);
|
_context->RSSetViewports(1, &view);
|
||||||
|
|
||||||
_blendState->Apply(*this);
|
_blendState->Apply();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,64 @@
|
|||||||
#include "device-dx.hpp"
|
#include "device-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
bool RasterizerState::Initialize(GraphicsDevice& device, xna_error_ptr_arg)
|
bool RasterizerState::Initialize(xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
const auto hr = device._device->CreateRasterizerState(&_description, &_rasterizerState);
|
if (!m_device || !m_device->_device) {
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
|
||||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const auto hr = m_device->_device->CreateRasterizerState(&dxDescription, &dxRasterizerState);
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::FAILED_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RasterizerState::Apply(xna_error_ptr_arg)
|
||||||
|
{
|
||||||
|
if (!m_device || !m_device->_context) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dxRasterizerState) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::UNINTIALIZED_RESOURCE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_device->_context->RSSetState(dxRasterizerState);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uptr<RasterizerState> RasterizerState::CullNone()
|
||||||
|
{
|
||||||
|
auto raster = std::unique_ptr<RasterizerState>(new RasterizerState());
|
||||||
|
raster->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
|
raster->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_NONE;
|
||||||
|
raster->dxDescription.DepthClipEnable = true;
|
||||||
|
return raster;
|
||||||
|
}
|
||||||
|
|
||||||
|
uptr<RasterizerState> RasterizerState::CullClockwise()
|
||||||
|
{
|
||||||
|
auto raster = std::unique_ptr<RasterizerState>(new RasterizerState());
|
||||||
|
raster->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
|
raster->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_FRONT;
|
||||||
|
raster->dxDescription.DepthClipEnable = true;
|
||||||
|
return raster;
|
||||||
|
}
|
||||||
|
|
||||||
|
uptr<RasterizerState> RasterizerState::CullCounterClockwise()
|
||||||
|
{
|
||||||
|
auto raster = std::unique_ptr<RasterizerState>(new RasterizerState());
|
||||||
|
raster->dxDescription.FillMode = D3D11_FILL_SOLID;
|
||||||
|
raster->dxDescription.CullMode = D3D11_CULL_MODE::D3D11_CULL_BACK;
|
||||||
|
raster->dxDescription.DepthClipEnable = true;
|
||||||
|
return raster;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,107 +2,50 @@
|
|||||||
#define XNA_PLATFORM_RASTERIZERSTATE_DX_HPP
|
#define XNA_PLATFORM_RASTERIZERSTATE_DX_HPP
|
||||||
|
|
||||||
#include "../graphics/rasterizerstate.hpp"
|
#include "../graphics/rasterizerstate.hpp"
|
||||||
|
#include "../graphics/gresource.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class RasterizerState : public IRasterizerState {
|
class RasterizerState : public IRasterizerState, public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
RasterizerState(){}
|
RasterizerState(GraphicsDevice* device) : GraphicsResource(device){}
|
||||||
|
|
||||||
virtual ~RasterizerState() override {
|
virtual ~RasterizerState() override {
|
||||||
if (_rasterizerState) {
|
if (dxRasterizerState) {
|
||||||
_rasterizerState->Release();
|
dxRasterizerState->Release();
|
||||||
_rasterizerState = nullptr;
|
dxRasterizerState = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, xna_error_nullarg) override;
|
virtual bool Initialize(xna_error_nullarg) override;
|
||||||
|
virtual bool Apply(xna_error_nullarg) override;
|
||||||
|
|
||||||
virtual constexpr xna::CullMode CullMode() const override {
|
virtual constexpr xna::CullMode CullMode() const override {
|
||||||
switch (_description.CullMode)
|
return static_cast<xna::CullMode>(static_cast<int>(dxDescription.CullMode) - 1);
|
||||||
{
|
|
||||||
case D3D11_CULL_NONE:
|
|
||||||
return xna::CullMode::None;
|
|
||||||
case D3D11_CULL_FRONT:
|
|
||||||
return xna::CullMode::CullClockwiseFace;
|
|
||||||
case D3D11_CULL_BACK:
|
|
||||||
return xna::CullMode::CullCounterClockwiseFace;
|
|
||||||
default:
|
|
||||||
return xna::CullMode::None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr void CullMode(xna::CullMode value) override {
|
virtual constexpr void CullMode(xna::CullMode value) override {
|
||||||
switch (value)
|
dxDescription.CullMode = static_cast<D3D11_CULL_MODE>(static_cast<int>(value) + 1);
|
||||||
{
|
|
||||||
case xna::CullMode::None:
|
|
||||||
_description.CullMode = D3D11_CULL_NONE;
|
|
||||||
break;
|
|
||||||
case xna::CullMode::CullClockwiseFace:
|
|
||||||
_description.CullMode = D3D11_CULL_FRONT;
|
|
||||||
break;
|
|
||||||
case xna::CullMode::CullCounterClockwiseFace:
|
|
||||||
_description.CullMode = D3D11_CULL_BACK;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_description.CullMode = D3D11_CULL_NONE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr xna::FillMode FillMode() const override {
|
virtual constexpr xna::FillMode FillMode() const override {
|
||||||
switch (_description.FillMode) {
|
return static_cast<xna::FillMode>(static_cast<int>(dxDescription.FillMode) - 2);
|
||||||
case D3D11_FILL_SOLID:
|
|
||||||
return xna::FillMode::Solid;
|
|
||||||
case D3D11_FILL_WIREFRAME:
|
|
||||||
return xna::FillMode::WireFrame;
|
|
||||||
default:
|
|
||||||
return xna::FillMode::Solid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr void FillMode(xna::FillMode value) override {
|
virtual constexpr void FillMode(xna::FillMode value) override {
|
||||||
switch (value)
|
dxDescription.FillMode = static_cast<D3D11_FILL_MODE>(static_cast<int>(value) + 2);
|
||||||
{
|
|
||||||
case xna::FillMode::Solid:
|
|
||||||
_description.FillMode = D3D11_FILL_SOLID;
|
|
||||||
break;
|
|
||||||
case xna::FillMode::WireFrame:
|
|
||||||
_description.FillMode = D3D11_FILL_WIREFRAME;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_description.FillMode = D3D11_FILL_SOLID;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRasterizerState CullNone() {
|
static uptr<RasterizerState> CullNone();
|
||||||
auto raster = New<RasterizerState>();
|
static uptr<RasterizerState> CullClockwise();
|
||||||
raster->_description.FillMode = D3D11_FILL_SOLID;
|
static uptr<RasterizerState> CullCounterClockwise();
|
||||||
raster->_description.CullMode = D3D11_CULL_MODE::D3D11_CULL_NONE;
|
|
||||||
raster->_description.DepthClipEnable = true;
|
|
||||||
return raster;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PRasterizerState CullClockwise() {
|
|
||||||
auto raster = New<RasterizerState>();
|
|
||||||
raster->_description.FillMode = D3D11_FILL_SOLID;
|
|
||||||
raster->_description.CullMode = D3D11_CULL_MODE::D3D11_CULL_FRONT;
|
|
||||||
raster->_description.DepthClipEnable = true;
|
|
||||||
return raster;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PRasterizerState CullCounterClockwise() {
|
|
||||||
auto raster = New<RasterizerState>();
|
|
||||||
raster->_description.FillMode = D3D11_FILL_SOLID;
|
|
||||||
raster->_description.CullMode = D3D11_CULL_MODE::D3D11_CULL_BACK;
|
|
||||||
raster->_description.DepthClipEnable = true;
|
|
||||||
return raster;
|
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ID3D11RasterizerState* _rasterizerState = nullptr;
|
ID3D11RasterizerState* dxRasterizerState = nullptr;
|
||||||
D3D11_RASTERIZER_DESC _description{};
|
D3D11_RASTERIZER_DESC dxDescription{};
|
||||||
|
|
||||||
|
private:
|
||||||
|
RasterizerState() : GraphicsResource(nullptr){}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,36 +68,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr void Comparison(ComparisonFunction value) override {
|
virtual constexpr void Comparison(ComparisonFunction value) override {
|
||||||
switch (value)
|
_description.ComparisonFunc = static_cast<D3D11_COMPARISON_FUNC>(static_cast<int>(value) + 1);
|
||||||
{
|
|
||||||
case xna::ComparisonFunction::Never:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::Less:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_LESS;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::Equal:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_EQUAL;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::LessEquals:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_LESS_EQUAL;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::Greater:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_GREATER;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::NotEqual:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_NOT_EQUAL;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::GreaterEqual:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_GREATER_EQUAL;
|
|
||||||
break;
|
|
||||||
case xna::ComparisonFunction::Always:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
_description.ComparisonFunc = D3D11_COMPARISON_NEVER;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr void MipLODBias(float value) override {
|
virtual constexpr void MipLODBias(float value) override {
|
||||||
@ -161,27 +132,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual ComparisonFunction Comparison() const override {
|
virtual ComparisonFunction Comparison() const override {
|
||||||
switch (_description.ComparisonFunc)
|
return static_cast<ComparisonFunction>(_description.ComparisonFunc - 1);
|
||||||
{
|
|
||||||
case D3D11_COMPARISON_NEVER :
|
|
||||||
return xna::ComparisonFunction::Never;
|
|
||||||
case D3D11_COMPARISON_LESS:
|
|
||||||
return xna::ComparisonFunction::Less;
|
|
||||||
case D3D11_COMPARISON_EQUAL:
|
|
||||||
return xna::ComparisonFunction::Equal;
|
|
||||||
case D3D11_COMPARISON_LESS_EQUAL:
|
|
||||||
return xna::ComparisonFunction::LessEquals;
|
|
||||||
case D3D11_COMPARISON_GREATER:
|
|
||||||
return xna::ComparisonFunction::Greater;
|
|
||||||
case D3D11_COMPARISON_NOT_EQUAL:
|
|
||||||
return xna::ComparisonFunction::NotEqual;
|
|
||||||
case D3D11_COMPARISON_GREATER_EQUAL:
|
|
||||||
return xna::ComparisonFunction::GreaterEqual;
|
|
||||||
case D3D11_COMPARISON_ALWAYS:
|
|
||||||
return xna::ComparisonFunction::Always;
|
|
||||||
default:
|
|
||||||
return xna::ComparisonFunction::Never;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual constexpr float MipLODBias() const override {
|
virtual constexpr float MipLODBias() const override {
|
||||||
@ -206,46 +157,11 @@ namespace xna {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr void ConvertAddressMode(TextureAddressMode value, D3D11_TEXTURE_ADDRESS_MODE& target) {
|
static constexpr void ConvertAddressMode(TextureAddressMode value, D3D11_TEXTURE_ADDRESS_MODE& target) {
|
||||||
switch (value)
|
target = static_cast<D3D11_TEXTURE_ADDRESS_MODE>(static_cast<int>(value) + 1);
|
||||||
{
|
|
||||||
case xna::TextureAddressMode::Wrap:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
||||||
break;
|
|
||||||
case xna::TextureAddressMode::Clamp:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_CLAMP;
|
|
||||||
break;
|
|
||||||
case xna::TextureAddressMode::Mirror:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_MIRROR;
|
|
||||||
break;
|
|
||||||
case xna::TextureAddressMode::Border:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_BORDER;
|
|
||||||
break;
|
|
||||||
case xna::TextureAddressMode::MirrorOnce:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_MIRROR_ONCE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
target = D3D11_TEXTURE_ADDRESS_WRAP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr void ConvertAddressMode(D3D11_TEXTURE_ADDRESS_MODE value, TextureAddressMode& target) {
|
static constexpr void ConvertAddressMode(D3D11_TEXTURE_ADDRESS_MODE value, TextureAddressMode& target) {
|
||||||
switch (value)
|
target = static_cast<TextureAddressMode>(value - 1);
|
||||||
{
|
|
||||||
case D3D11_TEXTURE_ADDRESS_WRAP:
|
|
||||||
target = TextureAddressMode::Wrap;
|
|
||||||
case D3D11_TEXTURE_ADDRESS_CLAMP:
|
|
||||||
target = TextureAddressMode::Clamp;
|
|
||||||
case D3D11_TEXTURE_ADDRESS_MIRROR:
|
|
||||||
target = TextureAddressMode::Mirror;
|
|
||||||
case D3D11_TEXTURE_ADDRESS_BORDER:
|
|
||||||
target = TextureAddressMode::Border;
|
|
||||||
case D3D11_TEXTURE_ADDRESS_MIRROR_ONCE:
|
|
||||||
target = TextureAddressMode::MirrorOnce;
|
|
||||||
default:
|
|
||||||
target = TextureAddressMode::Wrap;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -47,9 +47,9 @@ namespace xna {
|
|||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VertexShader::Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_ptr_arg)
|
bool VertexShader::Initialize(DataBuffer& buffer, xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!device._device || !buffer._blob) {
|
if (!m_device || !m_device->_device || !buffer._blob) {
|
||||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ namespace xna {
|
|||||||
_vertexShader = nullptr;
|
_vertexShader = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hr = device._device->CreateVertexShader(
|
const auto hr = m_device->_device->CreateVertexShader(
|
||||||
buffer._blob->GetBufferPointer(),
|
buffer._blob->GetBufferPointer(),
|
||||||
buffer._blob->GetBufferSize(),
|
buffer._blob->GetBufferSize(),
|
||||||
NULL,
|
NULL,
|
||||||
@ -73,9 +73,9 @@ namespace xna {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PixelShader::Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_ptr_arg)
|
bool PixelShader::Initialize(DataBuffer& buffer, xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
if (!device._device || !buffer._blob) {
|
if (!m_device || !m_device->_device || !buffer._blob) {
|
||||||
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ namespace xna {
|
|||||||
_pixelShader = nullptr;
|
_pixelShader = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hr = device._device->CreatePixelShader(
|
const auto hr = m_device->_device->CreatePixelShader(
|
||||||
buffer._blob->GetBufferPointer(),
|
buffer._blob->GetBufferPointer(),
|
||||||
buffer._blob->GetBufferSize(),
|
buffer._blob->GetBufferSize(),
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -2,23 +2,24 @@
|
|||||||
#define XNA_PLATFORM_SHADER_DX_HPP
|
#define XNA_PLATFORM_SHADER_DX_HPP
|
||||||
|
|
||||||
#include "../graphics/shader.hpp"
|
#include "../graphics/shader.hpp"
|
||||||
|
#include "../graphics/gresource.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class Shader : public IShader {
|
class Shader : public IShader, public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
Shader() = default;
|
Shader(GraphicsDevice* device) : GraphicsResource(device){}
|
||||||
|
|
||||||
virtual ~Shader() override {}
|
virtual ~Shader() override {}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_nullarg) override {}
|
virtual bool Initialize(DataBuffer& buffer, xna_error_nullarg) override {}
|
||||||
|
|
||||||
static HRESULT CompileFromFile(_In_ LPCWSTR srcFile, _In_ LPCSTR entryPoint, _In_ LPCSTR profile, _Outptr_ ID3DBlob** blob);
|
static HRESULT CompileFromFile(_In_ LPCWSTR srcFile, _In_ LPCSTR entryPoint, _In_ LPCSTR profile, _Outptr_ ID3DBlob** blob);
|
||||||
};
|
};
|
||||||
|
|
||||||
class VertexShader : public Shader {
|
class VertexShader : public Shader {
|
||||||
public:
|
public:
|
||||||
VertexShader() = default;
|
VertexShader(GraphicsDevice* device) : Shader(device){}
|
||||||
|
|
||||||
virtual ~VertexShader() override {
|
virtual ~VertexShader() override {
|
||||||
if (_vertexShader) {
|
if (_vertexShader) {
|
||||||
@ -27,7 +28,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_nullarg) override;
|
virtual bool Initialize(DataBuffer& buffer, xna_error_nullarg) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ID3D11VertexShader* _vertexShader = nullptr;
|
ID3D11VertexShader* _vertexShader = nullptr;
|
||||||
@ -35,7 +36,7 @@ namespace xna {
|
|||||||
|
|
||||||
class PixelShader : public Shader {
|
class PixelShader : public Shader {
|
||||||
public:
|
public:
|
||||||
PixelShader() = default;
|
PixelShader(GraphicsDevice* device) : Shader(device) {}
|
||||||
|
|
||||||
virtual ~PixelShader() override {
|
virtual ~PixelShader() override {
|
||||||
if (_pixelShader) {
|
if (_pixelShader) {
|
||||||
@ -44,7 +45,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, DataBuffer& buffer, xna_error_nullarg) override;
|
virtual bool Initialize(DataBuffer& buffer, xna_error_nullarg) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ID3D11PixelShader* _pixelShader = nullptr;
|
ID3D11PixelShader* _pixelShader = nullptr;
|
||||||
|
@ -17,6 +17,9 @@ using DirectX::GXMVECTOR;
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
SpriteBatch::SpriteBatch(GraphicsDevice& device) {
|
SpriteBatch::SpriteBatch(GraphicsDevice& device) {
|
||||||
|
if (!device._context)
|
||||||
|
return;
|
||||||
|
|
||||||
_dxspriteBatch = New<DxSpriteBatch>(device._context);
|
_dxspriteBatch = New<DxSpriteBatch>(device._context);
|
||||||
|
|
||||||
Viewport(device.Viewport());
|
Viewport(device.Viewport());
|
||||||
@ -42,8 +45,8 @@ namespace xna {
|
|||||||
sort,
|
sort,
|
||||||
blendState ? blendState->dxBlendState : nullptr,
|
blendState ? blendState->dxBlendState : nullptr,
|
||||||
samplerState ? samplerState->_samplerState : nullptr,
|
samplerState ? samplerState->_samplerState : nullptr,
|
||||||
depthStencil ? depthStencil->_depthStencil : nullptr,
|
depthStencil ? depthStencil->dxDepthStencil : nullptr,
|
||||||
rasterizerState ? rasterizerState->_rasterizerState : nullptr,
|
rasterizerState ? rasterizerState->dxRasterizerState : nullptr,
|
||||||
nullptr,
|
nullptr,
|
||||||
matrix
|
matrix
|
||||||
);
|
);
|
||||||
|
@ -44,27 +44,7 @@ namespace xna {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr void ConvertSpriteSort(SpriteSortMode value, DirectX::SpriteSortMode& target) {
|
static constexpr void ConvertSpriteSort(SpriteSortMode value, DirectX::SpriteSortMode& target) {
|
||||||
switch (value)
|
target = static_cast<DirectX::SpriteSortMode>(static_cast<int>(value));
|
||||||
{
|
|
||||||
case xna::SpriteSortMode::Deferred:
|
|
||||||
target = DirectX::SpriteSortMode_Deferred;
|
|
||||||
break;
|
|
||||||
case xna::SpriteSortMode::Immediate:
|
|
||||||
target = DirectX::SpriteSortMode_Immediate;
|
|
||||||
break;
|
|
||||||
case xna::SpriteSortMode::Texture:
|
|
||||||
target = DirectX::SpriteSortMode_Texture;
|
|
||||||
break;
|
|
||||||
case xna::SpriteSortMode::BackToFront:
|
|
||||||
target = DirectX::SpriteSortMode_BackToFront;
|
|
||||||
break;
|
|
||||||
case xna::SpriteSortMode::FrontToBack:
|
|
||||||
target = DirectX::SpriteSortMode_FrontToBack;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
target = DirectX::SpriteSortMode_Deferred;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -37,7 +37,12 @@ namespace xna {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwapChain::Initialize(GraphicsDevice& device, GameWindow const& gameWindow) {
|
bool SwapChain::Initialize(GameWindow const& gameWindow, xna_error_ptr_arg) {
|
||||||
|
if (!m_device || !m_device->_device) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const auto bounds = gameWindow.ClientBounds();
|
const auto bounds = gameWindow.ClientBounds();
|
||||||
|
|
||||||
dxDescription.Width = static_cast<UINT>(bounds.Width);
|
dxDescription.Width = static_cast<UINT>(bounds.Width);
|
||||||
@ -56,14 +61,19 @@ namespace xna {
|
|||||||
dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
dxFullScreenDescription.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
|
||||||
dxFullScreenDescription.Windowed = gameWindow.Mode() != GameWindowMode::Fullscreen;
|
dxFullScreenDescription.Windowed = gameWindow.Mode() != GameWindowMode::Fullscreen;
|
||||||
|
|
||||||
return internalInit(device, gameWindow, dxSwapChain, dxDescription, dxFullScreenDescription);
|
return internalInit(*m_device, gameWindow, dxSwapChain, dxDescription, dxFullScreenDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwapChain::Initialize(GraphicsDevice& device, GameWindow const& gameWindow, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fullScreenDesc)
|
bool SwapChain::Initialize(GameWindow const& gameWindow, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fullScreenDesc, xna_error_ptr_arg)
|
||||||
{
|
{
|
||||||
|
if (!m_device || !m_device->_device) {
|
||||||
|
xna_error_apply(err, XnaErrorCode::INVALID_OPERATION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
dxDescription = desc;
|
dxDescription = desc;
|
||||||
dxFullScreenDescription = fullScreenDesc;
|
dxFullScreenDescription = fullScreenDesc;
|
||||||
return internalInit(device, gameWindow, dxSwapChain, dxDescription, dxFullScreenDescription);
|
return internalInit(*m_device, gameWindow, dxSwapChain, dxDescription, dxFullScreenDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwapChain::GetBackBuffer(ID3D11Texture2D*& texture2D) {
|
bool SwapChain::GetBackBuffer(ID3D11Texture2D*& texture2D) {
|
||||||
|
@ -4,10 +4,13 @@
|
|||||||
#include "../graphics/swapchain.hpp"
|
#include "../graphics/swapchain.hpp"
|
||||||
#include "window-dx.hpp"
|
#include "window-dx.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
#include "../graphics/gresource.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class SwapChain : public ISwapChain{
|
class SwapChain : public ISwapChain, public GraphicsResource {
|
||||||
public:
|
public:
|
||||||
|
SwapChain(GraphicsDevice* device): GraphicsResource(device){}
|
||||||
|
|
||||||
virtual ~SwapChain() override {
|
virtual ~SwapChain() override {
|
||||||
if (dxSwapChain) {
|
if (dxSwapChain) {
|
||||||
dxSwapChain->Release();
|
dxSwapChain->Release();
|
||||||
@ -15,8 +18,8 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool Initialize(GraphicsDevice& device, GameWindow const& gameWindow) override;
|
virtual bool Initialize(GameWindow const& gameWindow, xna_error_nullarg) override;
|
||||||
bool Initialize(GraphicsDevice& device, GameWindow const& gameWindow, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fullScreenDesc);
|
bool Initialize(GameWindow const& gameWindow, DXGI_SWAP_CHAIN_DESC1 const& desc, DXGI_SWAP_CHAIN_FULLSCREEN_DESC const& fullScreenDesc, xna_error_nullarg);
|
||||||
|
|
||||||
bool GetBackBuffer(ID3D11Texture2D*& texture2D);
|
bool GetBackBuffer(ID3D11Texture2D*& texture2D);
|
||||||
|
|
||||||
|
@ -26,18 +26,6 @@ namespace xna {
|
|||||||
|
|
||||||
XnaErrorCode err;
|
XnaErrorCode err;
|
||||||
texture = Texture2D::FromStream(*_graphicsDevice, "D:\\sprite.jpg", &err);
|
texture = Texture2D::FromStream(*_graphicsDevice, "D:\\sprite.jpg", &err);
|
||||||
|
|
||||||
std::vector<VertexPositionColor> data(3);
|
|
||||||
data[0] = VertexPositionColor(Vector3(0.0F, 0.5F, 0.5F), Colors::AliceBlue);
|
|
||||||
data[0] = VertexPositionColor(Vector3(0.5F, -0.5F, 0.5F), Colors::Red);
|
|
||||||
data[0] = VertexPositionColor(Vector3(-0.5F, -0.5F, 0.5F), Colors::AliceBlue);
|
|
||||||
|
|
||||||
VertexBuffer<VertexPositionColor> vbuffer(_graphicsDevice.get(), data);
|
|
||||||
vbuffer.Initialize(&err);
|
|
||||||
|
|
||||||
D3D11_BUFFER_DESC desc;
|
|
||||||
vbuffer.dxBuffer->GetDesc(&desc);
|
|
||||||
|
|
||||||
|
|
||||||
Game::LoadContent();
|
Game::LoadContent();
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ namespace xna {
|
|||||||
OVERFLOW_OPERATION,
|
OVERFLOW_OPERATION,
|
||||||
NULL_CAST,
|
NULL_CAST,
|
||||||
BAD_CAST,
|
BAD_CAST,
|
||||||
STREAM_ERROR
|
STREAM_ERROR,
|
||||||
|
UNINTIALIZED_RESOURCE
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void xna_error_apply(XnaErrorCode* source, XnaErrorCode const& value) {
|
inline void xna_error_apply(XnaErrorCode* source, XnaErrorCode const& value) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user