1
0
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:
Danilo 2024-04-24 11:44:41 -03:00
parent aef3e85b5d
commit c3df41bdab
8 changed files with 35 additions and 47 deletions

View File

@ -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;

View File

@ -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<BlendRenderTarget>;
struct BlendRenderTarget;
class IBlendState {
public:

View File

@ -1,5 +1,4 @@
#include "adapter-dx.hpp"
#include "../helpers.hpp"
#include "gdevicemanager-dx.hpp"
namespace xna {

View File

@ -5,6 +5,7 @@
#include "displaymode-dx.hpp"
#include "dxheaders.hpp"
namespace xna {
class GraphicsAdapter : public IGraphicsAdapter {
public:

View File

@ -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>();
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>();
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>();
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;
}

View File

@ -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<D3D11_BLEND_OP>(static_cast<int>(op) + 1);
}
static constexpr D3D11_COLOR_WRITE_ENABLE ConvertColorWrite(ColorWriteChannels colorWrite) {

View File

@ -252,7 +252,7 @@ namespace xna {
private:
GamePadCapabilitiesType _type{};
bool _connected{ false };
GamePadId _id;
GamePadId _id{};
Ushort _vid{ 0 };
Ushort _pid{ 0 };
};

View File

@ -1 +1,5 @@
#include "keyboard-dx.hpp"
#include "keyboard-dx.hpp"
namespace xna {
}