[slimdx] r2178 committed - Added a few convenience methods to the D3D11 pipeline wrappers.

1 view
Skip to first unread message

sli...@googlecode.com

unread,
Mar 5, 2012, 12:08:05 AM3/5/12
to slimdx...@googlegroups.com
Revision: 2178
Author: mike.popoloski
Date: Sun Mar 4 21:06:29 2012
Log: Added a few convenience methods to the D3D11 pipeline wrappers.
http://code.google.com/p/slimdx/source/detail?r=2178

Modified:
/trunk/source/direct3d11/OutputMergerWrapper11.cpp
/trunk/source/direct3d11/OutputMergerWrapper11.h
/trunk/source/direct3d11/RasterizerWrapper11.cpp
/trunk/source/direct3d11/RasterizerWrapper11.h

=======================================
--- /trunk/source/direct3d11/OutputMergerWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/OutputMergerWrapper11.cpp Sun Mar 4 21:06:29
2012
@@ -172,6 +172,39 @@

return oldMask;
}
+
+ void
OutputMergerWrapper::GetDepthStencilState(SlimDX::Direct3D11::DepthStencilState^ %state,
int %reference)
+ {
+ ID3D11DepthStencilState* result = 0;
+ UINT ref = 0;
+ deviceContext->OMGetDepthStencilState(&result, &ref);
+
+ reference = ref;
+ state = SlimDX::Direct3D11::DepthStencilState::FromPointer(result);
+ }
+
+ void
OutputMergerWrapper::SetDepthStencilState(SlimDX::Direct3D11::DepthStencilState^
state, int reference )
+ {
+ deviceContext->OMSetDepthStencilState(state == nullptr ? 0 :
state->InternalPointer, reference);
+ }
+
+ void
OutputMergerWrapper::GetBlendState(SlimDX::Direct3D11::BlendState^ %state,
Color4 %blendFactor, int %sampleMask)
+ {
+ ID3D11BlendState *outState;
+ float outFactor[4];
+ UINT outMask;
+
+ deviceContext->OMGetBlendState(&outState, outFactor, &outMask);
+
+ state = SlimDX::Direct3D11::BlendState::FromPointer(outState);
+ blendFactor = Color4(outFactor[3], outFactor[0], outFactor[1],
outFactor[2]);
+ sampleMask = outMask;
+ }
+
+ void OutputMergerWrapper::SetBlendState(SlimDX::Direct3D11::BlendState^
state, Color4 blendFactor, int sampleMask)
+ {
+ deviceContext->OMSetBlendState(state == nullptr ? 0 :
state->InternalPointer, reinterpret_cast<float*>(&blendFactor), sampleMask);
+ }

void OutputMergerWrapper::SetTargets( RenderTargetView^ renderTargetView )
{
=======================================
--- /trunk/source/direct3d11/OutputMergerWrapper11.h Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/OutputMergerWrapper11.h Sun Mar 4 21:06:29
2012
@@ -89,6 +89,36 @@
void set( int value );
int get();
}
+
+ /// <summary>
+ /// Gets the depth-stencil state of the output-merger stage.
+ /// </summary>
+ /// <param name="state">Returns the currently set depth-stencil
state.</param>
+ /// <param name="reference">Returns the current depth-stencil reference
value.</param>
+ void
GetDepthStencilState(SlimDX::Direct3D11::DepthStencilState^ %state,
int %reference);
+
+ /// <summary>
+ /// Sets the depth-stencil state of the output-merger stage.
+ /// </summary>
+ /// <param name="state">The depth-stencil state to set.</param>
+ /// <param name="reference">The depth-stencil reference value to
set.</param>
+ void SetDepthStencilState(SlimDX::Direct3D11::DepthStencilState^ state,
int reference);
+
+ /// <summary>
+ /// Gets the blend state of the output-merger stage.
+ /// </summary>
+ /// <param name="state">Returns the currently set blend state.</param>
+ /// <param name="blendFactor">Returns the current blending
factor.</param>
+ /// <param name="sampleMask">Returns the current sampling mask.</param>
+ void GetBlendState(SlimDX::Direct3D11::BlendState^ %state,
Color4 %blendFactor, int %sampleMask);
+
+ /// <summary>
+ /// Sets the blend state of the output-merger stage.
+ /// </summary>
+ /// <param name="state">The blend state to set.</param>
+ /// <param name="blendFactor">The blending factor to set.</param>
+ /// <param name="sampleMask">The sampling mask to set.</param>
+ void SetBlendState(SlimDX::Direct3D11::BlendState^ state, Color4
blendFactor, int sampleMask);

/// <summary>
/// Binds a single render target to the output-merger stage.
=======================================
--- /trunk/source/direct3d11/RasterizerWrapper11.cpp Sat Jan 28 10:03:11
2012
+++ /trunk/source/direct3d11/RasterizerWrapper11.cpp Sun Mar 4 21:06:29
2012
@@ -111,6 +111,15 @@
viewports[i] = Viewport( nativeVPs[i].TopLeftX, nativeVPs[i].TopLeftY,
nativeVPs[i].Width, nativeVPs[i].Height, nativeVPs[i].MinDepth,
nativeVPs[i].MaxDepth );
return viewports;
}
+
+ Viewport RasterizerWrapper::GetViewport()
+ {
+ D3D11_VIEWPORT vp;
+ UINT count = 1;
+
+ deviceContext->RSGetViewports(&count, &vp);
+ return Viewport(vp.TopLeftX, vp.TopLeftY, vp.Width, vp.Height,
vp.MinDepth, vp.MaxDepth);
+ }

void RasterizerWrapper::SetScissorRectangles( System::Drawing::Rectangle
scissorRectangle )
{
=======================================
--- /trunk/source/direct3d11/RasterizerWrapper11.h Sat Jan 28 10:03:11 2012
+++ /trunk/source/direct3d11/RasterizerWrapper11.h Sun Mar 4 21:06:29 2012
@@ -74,6 +74,12 @@
/// <returns>An array of bound viewports.</returns>
array<Viewport>^ GetViewports();

+ /// <summary>
+ /// Gets the first viewport currently bound to the rasterizer stage.
+ /// </summary>
+ /// <returns>The first bound viewport.</returns>
+ Viewport GetViewport();
+
/// <summary>
/// Binds a single scissor rectangle to the rasterizer stage.
/// </summary>

Reply all
Reply to author
Forward
0 new messages