I hope this isn't something stupid that I've missed or did wrong, but I am stumped at this point and thought perhaps someone else using the TK had found something similar. The problem I am running into is that everything works 100% fine until I call SpriteBatch.End
and at that point I get an error saying "Unhandled exception at <address> (msvdr110d.dll) in <myexe>. An invalid parameter was passed to a function that considers invalid parameters fatal." This is actually inside a C# application using
a SurfaceImageSource written in C++ to use DirectX, I have managed successfully draw using Direct2D (I only tried primitives, like lines and rectangles) but would rather use the Toolkit for SpriteBatch and having the DDSTextureFromFile functions. The app targets
W8 Store, I have the DirectX stuff inside a WinRT component that I am writing.
I have a BeginDraw function that allows me to draw to sections of my underlying surface that looks like the following:
void MyImageSourceType::BeginDraw(Windows::Foundation::Rect updateRect)
// Express target area as a native RECT type.
updateRectNative.left = static_cast<LONG>(updateRect.Left);
updateRectNative.top = static_cast<LONG>(updateRect.Top);
updateRectNative.right = static_cast<LONG>(updateRect.Right);
updateRectNative.bottom = static_cast<LONG>(updateRect.Bottom);
// Begin drawing - returns a target surface and an offset
// to use as the top-left origin when drawing.
HRESULT beginDrawHR = m_sisNative->BeginDraw(
updateRectNative, &surface, &offset);
if (beginDrawHR == DXGI_ERROR_DEVICE_REMOVED ||
beginDrawHR == DXGI_ERROR_DEVICE_RESET)
// If the device has been removed or reset, attempt to
// re-create it and continue drawing.
m_d3dDevice->CreateRenderTargetView(texture.Get(), nullptr, &m_d3dRenderTargetView);
auto context = m_d3dDeviceContext;
auto renderTarget = m_d3dRenderTargetView;
auto depthStencil = m_d3dDepthStencilView.Get();
//context->ClearDepthStencilView(depthStencil, D3D11_CLEAR_DEPTH, 1.0F, 0);
context->OMSetRenderTargets(1, &renderTarget, depthStencil);
And my simple draw code and EndDraw look like the following:
void MyImageSourceType::DrawPoint(int x, int y)
I have followed the example from
to get this all set up drawing to an image.
My setting up of the spritebatch is at the end of my CreateDeviceResources() function and is simply the following:
CreateDDSTextureFromFile(m_d3dDevice.Get(), L"assets\\windowslogo.dds", nullptr, m_texNote1.ReleaseAndGetAddressOf());
I stepped through and it seems like everything is setting up and loading correctly, I know I don't have HRESULT checks in here but I went through 1-by-1 and made sure everything was giving S_OK before posting (and it was).
If you can explain to me how to set up debugging to also step through the toolkit code I can find more specifics for where things are going wrong?
DirectXTK version: 22.214.171.124 (installed via nuget)
VS2012, Im running Win8.1 but targeting Win8 with the project.
Any other information that can help you I am happy to add in here.
Thanks in advance for you help!