diff --git a/framework/graphics/adapter.hpp b/framework/graphics/adapter.hpp index 081baa5..929fad3 100644 --- a/framework/graphics/adapter.hpp +++ b/framework/graphics/adapter.hpp @@ -1,15 +1,12 @@ #ifndef XNA_GRAPHICS_ADAPTER_HPP #define XNA_GRAPHICS_ADAPTER_HPP -#include "../enums.hpp" -#include "../types.hpp" -#include "../forward.hpp" -#include "displaymode.hpp" +#include "../default.hpp" namespace xna { class IGraphicsAdapter { public: - virtual ~IGraphicsAdapter() {} + virtual ~IGraphicsAdapter() {} virtual String Description() const = 0; virtual Uint DeviceId() const = 0; diff --git a/framework/graphics/blendstate.hpp b/framework/graphics/blendstate.hpp index 0aa64b5..6dfa9db 100644 --- a/framework/graphics/blendstate.hpp +++ b/framework/graphics/blendstate.hpp @@ -4,20 +4,7 @@ #include "../default.hpp" namespace xna { - struct BlendRenderTarget { - bool Enabled{ true }; - Blend Source{ Blend::SourceAlpha }; - Blend Destination{ Blend::InverseSourceAlpha }; - BlendOperation Operation{ BlendOperation::Add }; - Blend SourceAlpha{ Blend::One }; - Blend DestinationAlpha{ Blend::Zero }; - BlendOperation OperationAlpha{ BlendOperation::Add }; - ColorWriteChannels WriteMask{ ColorWriteChannels::All }; - - constexpr BlendRenderTarget() = default; - }; - - using PBlendRenderTarget = sptr; + struct BlendRenderTarget; class IBlendState { public: diff --git a/framework/platform/adapter-dx.cpp b/framework/platform/adapter-dx.cpp index 8bf3ab8..7750a59 100644 --- a/framework/platform/adapter-dx.cpp +++ b/framework/platform/adapter-dx.cpp @@ -1,5 +1,4 @@ #include "adapter-dx.hpp" -#include "../helpers.hpp" #include "gdevicemanager-dx.hpp" namespace xna { diff --git a/framework/platform/adapter-dx.hpp b/framework/platform/adapter-dx.hpp index 5266b4c..df74c35 100644 --- a/framework/platform/adapter-dx.hpp +++ b/framework/platform/adapter-dx.hpp @@ -5,6 +5,7 @@ #include "displaymode-dx.hpp" #include "dxheaders.hpp" + namespace xna { class GraphicsAdapter : public IGraphicsAdapter { public: diff --git a/framework/platform/blendstate-dx.cpp b/framework/platform/blendstate-dx.cpp index d6a369f..eeb315b 100644 --- a/framework/platform/blendstate-dx.cpp +++ b/framework/platform/blendstate-dx.cpp @@ -34,16 +34,16 @@ namespace xna { const auto init = Initialize(device, err); if (!init) return false; } - - device._context->OMSetBlendState(_blendState, nullptr, 0xffffffff); + + device._context->OMSetBlendState(_blendState, blendFactor, sampleMask); return true; } PBlendState IBlendState::Opaque() { auto blendState = New(); - blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; - blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; + blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; + blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO; blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA; blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO; @@ -54,8 +54,8 @@ namespace xna { auto blendState = New(); blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE; blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ONE; - blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_INV_DEST_ALPHA; - blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_DEST_ALPHA; + blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; return blendState; } @@ -74,8 +74,8 @@ namespace xna { auto blendState = New(); blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA; blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA; - blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_INV_DEST_ALPHA; - blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_DEST_ALPHA; + blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_INV_SRC_ALPHA; + blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA; return blendState; } diff --git a/framework/platform/blendstate-dx.hpp b/framework/platform/blendstate-dx.hpp index 616ea4c..830ca53 100644 --- a/framework/platform/blendstate-dx.hpp +++ b/framework/platform/blendstate-dx.hpp @@ -2,10 +2,22 @@ #define XNA_PLATFORM_BLENDSTATE_HPP #include "../graphics/blendstate.hpp" -#include "dxgi.h" -#include "d3d11.h" +#include "dxheaders.hpp" namespace xna { + struct BlendRenderTarget { + bool Enabled{ true }; + Blend Source{ Blend::SourceAlpha }; + Blend Destination{ Blend::InverseSourceAlpha }; + BlendOperation Operation{ BlendOperation::Add }; + Blend SourceAlpha{ Blend::One }; + Blend DestinationAlpha{ Blend::Zero }; + BlendOperation OperationAlpha{ BlendOperation::Add }; + ColorWriteChannels WriteMask{ ColorWriteChannels::All }; + + constexpr BlendRenderTarget() = default; + }; + class BlendState : public IBlendState { public: BlendState() = default; @@ -44,6 +56,8 @@ namespace xna { public: ID3D11BlendState* _blendState{ nullptr }; D3D11_BLEND_DESC _description{}; + float blendFactor[4] { 1.0F, 1.0F, 1.0F, 1.0F }; + UINT sampleMask{ 0xffffffff }; public: static constexpr D3D11_BLEND ConvertBlend(Blend blend) { @@ -89,21 +103,7 @@ namespace xna { } static constexpr D3D11_BLEND_OP ConvertOperation(BlendOperation op) { - switch (op) - { - case BlendOperation::Add: - return D3D11_BLEND_OP_ADD; - case BlendOperation::Subtract: - return D3D11_BLEND_OP_SUBTRACT; - case BlendOperation::ReverseSubtract: - return D3D11_BLEND_OP_REV_SUBTRACT; - case BlendOperation::Min: - return D3D11_BLEND_OP_MIN; - case BlendOperation::Max: - return D3D11_BLEND_OP_MAX; - default: - return D3D11_BLEND_OP_ADD; - } + return static_cast(static_cast(op) + 1); } static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) { diff --git a/framework/platform/gamepad-dx.hpp b/framework/platform/gamepad-dx.hpp index 57d0d01..72ae842 100644 --- a/framework/platform/gamepad-dx.hpp +++ b/framework/platform/gamepad-dx.hpp @@ -252,7 +252,7 @@ namespace xna { private: GamePadCapabilitiesType _type{}; bool _connected{ false }; - GamePadId _id; + GamePadId _id{}; Ushort _vid{ 0 }; Ushort _pid{ 0 }; }; diff --git a/framework/platform/keyboard-dx.cpp b/framework/platform/keyboard-dx.cpp index c3931de..dade6e9 100644 --- a/framework/platform/keyboard-dx.cpp +++ b/framework/platform/keyboard-dx.cpp @@ -1 +1,5 @@ -#include "keyboard-dx.hpp" \ No newline at end of file +#include "keyboard-dx.hpp" + +namespace xna { + +} \ No newline at end of file