mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em BlendState
This commit is contained in:
parent
aef3e85b5d
commit
c3df41bdab
@ -1,15 +1,12 @@
|
|||||||
#ifndef XNA_GRAPHICS_ADAPTER_HPP
|
#ifndef XNA_GRAPHICS_ADAPTER_HPP
|
||||||
#define XNA_GRAPHICS_ADAPTER_HPP
|
#define XNA_GRAPHICS_ADAPTER_HPP
|
||||||
|
|
||||||
#include "../enums.hpp"
|
#include "../default.hpp"
|
||||||
#include "../types.hpp"
|
|
||||||
#include "../forward.hpp"
|
|
||||||
#include "displaymode.hpp"
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class IGraphicsAdapter {
|
class IGraphicsAdapter {
|
||||||
public:
|
public:
|
||||||
virtual ~IGraphicsAdapter() {}
|
virtual ~IGraphicsAdapter() {}
|
||||||
|
|
||||||
virtual String Description() const = 0;
|
virtual String Description() const = 0;
|
||||||
virtual Uint DeviceId() const = 0;
|
virtual Uint DeviceId() const = 0;
|
||||||
|
@ -4,20 +4,7 @@
|
|||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
struct BlendRenderTarget {
|
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<BlendRenderTarget>;
|
|
||||||
|
|
||||||
class IBlendState {
|
class IBlendState {
|
||||||
public:
|
public:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#include "adapter-dx.hpp"
|
#include "adapter-dx.hpp"
|
||||||
#include "../helpers.hpp"
|
|
||||||
#include "gdevicemanager-dx.hpp"
|
#include "gdevicemanager-dx.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "displaymode-dx.hpp"
|
#include "displaymode-dx.hpp"
|
||||||
#include "dxheaders.hpp"
|
#include "dxheaders.hpp"
|
||||||
|
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
class GraphicsAdapter : public IGraphicsAdapter {
|
class GraphicsAdapter : public IGraphicsAdapter {
|
||||||
public:
|
public:
|
||||||
|
@ -34,16 +34,16 @@ namespace xna {
|
|||||||
const auto init = Initialize(device, err);
|
const auto init = Initialize(device, err);
|
||||||
if (!init) return false;
|
if (!init) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
device._context->OMSetBlendState(_blendState, nullptr, 0xffffffff);
|
device._context->OMSetBlendState(_blendState, blendFactor, sampleMask);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PBlendState IBlendState::Opaque() {
|
PBlendState IBlendState::Opaque() {
|
||||||
auto blendState = New<BlendState>();
|
auto blendState = New<BlendState>();
|
||||||
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||||
blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_SRC_ALPHA;
|
blendState->_description.RenderTarget[0].SrcBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
blendState->_description.RenderTarget[0].DestBlend = D3D11_BLEND_DEST_ALPHA;
|
||||||
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_ZERO;
|
||||||
|
|
||||||
@ -54,8 +54,8 @@ namespace xna {
|
|||||||
auto blendState = New<BlendState>();
|
auto blendState = New<BlendState>();
|
||||||
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_ONE;
|
||||||
blendState->_description.RenderTarget[0].SrcBlendAlpha = 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].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_DEST_ALPHA;
|
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
|
|
||||||
return blendState;
|
return blendState;
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ namespace xna {
|
|||||||
auto blendState = New<BlendState>();
|
auto blendState = New<BlendState>();
|
||||||
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
blendState->_description.RenderTarget[0].SrcBlend = D3D11_BLEND_SRC_ALPHA;
|
||||||
blendState->_description.RenderTarget[0].SrcBlendAlpha = 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].DestBlend = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_DEST_ALPHA;
|
blendState->_description.RenderTarget[0].DestBlendAlpha = D3D11_BLEND_INV_SRC_ALPHA;
|
||||||
|
|
||||||
return blendState;
|
return blendState;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,22 @@
|
|||||||
#define XNA_PLATFORM_BLENDSTATE_HPP
|
#define XNA_PLATFORM_BLENDSTATE_HPP
|
||||||
|
|
||||||
#include "../graphics/blendstate.hpp"
|
#include "../graphics/blendstate.hpp"
|
||||||
#include "dxgi.h"
|
#include "dxheaders.hpp"
|
||||||
#include "d3d11.h"
|
|
||||||
|
|
||||||
namespace xna {
|
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 {
|
class BlendState : public IBlendState {
|
||||||
public:
|
public:
|
||||||
BlendState() = default;
|
BlendState() = default;
|
||||||
@ -44,6 +56,8 @@ namespace xna {
|
|||||||
public:
|
public:
|
||||||
ID3D11BlendState* _blendState{ nullptr };
|
ID3D11BlendState* _blendState{ nullptr };
|
||||||
D3D11_BLEND_DESC _description{};
|
D3D11_BLEND_DESC _description{};
|
||||||
|
float blendFactor[4] { 1.0F, 1.0F, 1.0F, 1.0F };
|
||||||
|
UINT sampleMask{ 0xffffffff };
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
static constexpr D3D11_BLEND ConvertBlend(Blend blend) {
|
||||||
@ -89,21 +103,7 @@ namespace xna {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static constexpr D3D11_BLEND_OP ConvertOperation(BlendOperation op) {
|
static constexpr D3D11_BLEND_OP ConvertOperation(BlendOperation op) {
|
||||||
switch (op)
|
return static_cast<D3D11_BLEND_OP>(static_cast<int>(op) + 1);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) {
|
static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) {
|
||||||
|
@ -252,7 +252,7 @@ namespace xna {
|
|||||||
private:
|
private:
|
||||||
GamePadCapabilitiesType _type{};
|
GamePadCapabilitiesType _type{};
|
||||||
bool _connected{ false };
|
bool _connected{ false };
|
||||||
GamePadId _id;
|
GamePadId _id{};
|
||||||
Ushort _vid{ 0 };
|
Ushort _vid{ 0 };
|
||||||
Ushort _pid{ 0 };
|
Ushort _pid{ 0 };
|
||||||
};
|
};
|
||||||
|
@ -1 +1,5 @@
|
|||||||
#include "keyboard-dx.hpp"
|
#include "keyboard-dx.hpp"
|
||||||
|
|
||||||
|
namespace xna {
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user