mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
Added BlendState
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using DirectX.D3D11;
|
||||
using DirectX.Common;
|
||||
using GlitchyEngine.Math;
|
||||
|
||||
using internal GlitchyEngine.Renderer;
|
||||
|
||||
namespace GlitchyEngine.Renderer
|
||||
{
|
||||
extension BlendState
|
||||
{
|
||||
internal ID3D11BlendState* nativeBlendState ~ _?.Release();
|
||||
|
||||
public override void Bind(ColorRGBA blendFactor)
|
||||
{
|
||||
_context.nativeContext.OutputMerger.SetBlendState(nativeBlendState, blendFactor);
|
||||
}
|
||||
|
||||
protected override void PlatformCreateBlendState()
|
||||
{
|
||||
BlendDescription nativeDesc = .Default;
|
||||
nativeDesc.IndependentBlendEnable = _desc.IndependentBlendEnable;
|
||||
nativeDesc.AlphaToCoverageEnable = _desc.AlphaToCoverageEnable;
|
||||
|
||||
for(int i = 0; i < 8; i++)
|
||||
{
|
||||
nativeDesc.RenderTarget[i].BlendEnable = _desc.RenderTarget[i].BlendEnable;
|
||||
nativeDesc.RenderTarget[i].SourceBlend = _desc.RenderTarget[i].SourceBlend;
|
||||
nativeDesc.RenderTarget[i].DestinationBlend = _desc.RenderTarget[i].DestinationBlend;
|
||||
nativeDesc.RenderTarget[i].BlendOperation = _desc.RenderTarget[i].BlendOperation;
|
||||
nativeDesc.RenderTarget[i].SourceBlendAlpha = _desc.RenderTarget[i].SourceBlendAlpha;
|
||||
nativeDesc.RenderTarget[i].DestinationBlendAlpha = _desc.RenderTarget[i].DestinationBlendAlpha;
|
||||
nativeDesc.RenderTarget[i].BlendOperationAlpha = _desc.RenderTarget[i].BlendOperationAlpha;
|
||||
nativeDesc.RenderTarget[i].RenderTargetWriteMask = _desc.RenderTarget[i].RenderTargetWriteMask;
|
||||
}
|
||||
|
||||
HResult result = _context.nativeDevice.CreateBlendState(ref nativeDesc, &nativeBlendState);
|
||||
|
||||
Log.EngineLogger.Assert(result.Succeeded, scope $"Failed to create blend state. Error({(int)result}): {result}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,11 @@ namespace GlitchyEngine.Renderer
|
||||
|
||||
public static override API Api => .D3D11;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Clear(RenderTarget renderTarget, ColorRGBA clearColor)
|
||||
{
|
||||
_context.ClearRenderTarget(renderTarget, clearColor);
|
||||
|
||||
Reference in New Issue
Block a user