Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Inc/SpriteBatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ namespace DirectX
// Set viewport for sprite transformation
DIRECTX_TOOLKIT_API void __cdecl SetViewport(const D3D11_VIEWPORT& viewPort);

// Gets transform matrix based on viewport (which may be read from the device context) and rotation mode
DIRECTX_TOOLKIT_API void GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, XMMATRIX& transformMatrix) const;

private:
// Private implementation.
struct Impl;
Expand Down
10 changes: 9 additions & 1 deletion Src/SpriteBatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ XM_ALIGNED_STRUCT(16) SpriteBatch::Impl : public AlignedNew<SpriteBatch::Impl>
bool mSetViewport;
D3D11_VIEWPORT mViewPort;

XMMATRIX GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation);

private:
// Implementation helper methods.
void GrowSpriteQueue();
Expand All @@ -125,7 +127,6 @@ XM_ALIGNED_STRUCT(16) SpriteBatch::Impl : public AlignedNew<SpriteBatch::Impl>
FXMVECTOR inverseTextureSize);

static XMVECTOR GetTextureSize(_In_ ID3D11ShaderResourceView* texture);
XMMATRIX GetViewportTransform(_In_ ID3D11DeviceContext* deviceContext, DXGI_MODE_ROTATION rotation);


// Constants.
Expand Down Expand Up @@ -1192,3 +1193,10 @@ void SpriteBatch::SetViewport(const D3D11_VIEWPORT& viewPort)
pImpl->mSetViewport = true;
pImpl->mViewPort = viewPort;
}


_Use_decl_annotations_
void SpriteBatch::GetViewportTransform(ID3D11DeviceContext* deviceContext, XMMATRIX& transformMatrix) const
{
transformMatrix = pImpl->GetViewportTransform(deviceContext, pImpl->mRotation);
}
Loading