Drawing a primitive batch in screen space, and build DXTK as 32-bit?

Feb 28, 2015 at 5:35 PM
Edited Feb 28, 2015 at 5:36 PM
Hello,

Is there a way to draw a PrimitiveBatch in screen space (like you can with SpriteBatch)? Or do I need to roll my own solution?

Secondly, I may have missed documentation on this issue, but when trying to build a DirectXTK project as win32 I get a lot of errors such as

"Error 47 error C2061: syntax error : identifier 'DXGI_RGBA' 1275"

and

"Error 4 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 943" at D2D1_PIXEL_FORMAT PixelFormat;

Is there something I have missed with setting up the build options in visual studio?

I am using Visual Studio 2013 and the file "DirectXTK for Audio Simple Win32 Sample (Windows 8.x)" located here https://code.msdn.microsoft.com/windowsdesktop/DirectXTK-for-Audio-Simple-9d6a7da2#content

Thanks for your assistance on these matters. The DXTK is a godsend.
Coordinator
Mar 1, 2015 at 5:54 PM
Edited Mar 1, 2015 at 5:56 PM
Primitive batch draws with whatever effect/shader you have set up, so you can easily set up a screen-space based vertex shader and draw with that. There is probably a way to achieve that with BasicEffect actually, but I'll need to think about it a bit...

When you loaded that sample's solution with VS 2013, did you allow it to "Upgrade VC++ Compiler sand Libraries" for all three projects? I was able to download it, upgrade it with VS 2013, and then build most configurations without any problems. It looks like the "Profile | Win32" configuration isn't setup correctly though and the "Profile" configurations look kinda mess up generally. I'll take a look at that.

Those build errors look really odd, and historically reports like this indicated some kind of mix-up of the Windows SDK and the legacy DirectX SDK. Try setting up a project as described in the tutorial to see if it works for you.
Coordinator
Mar 7, 2015 at 2:23 AM
Edited Mar 7, 2015 at 2:25 AM
Note I've updated the PrimitiveBatch tutorial to demonstrate drawing in screen space rather than normalized space. The projection matrix which matches SpriteBatch is as follows (using SimpleMath):
Matrix proj = Matrix::CreateScale( 2.f/viewPort.Width, -2.f/viewPort.Height, 1.f)
   * Matrix::CreateTranslation( -1.f, 1.f, 0.f );
effect->SetProjection(proj);
Also, take a look at SpriteBatch::Impl::GetViewportTransform in SpriteBatch.cpp for the complete logic if you want to support the orientation settings as well.
Marked as answer by walbourn on 3/6/2015 at 7:25 PM
Mar 7, 2015 at 4:14 AM
Edited Mar 24, 2015 at 2:30 PM
Hi walbourn,

"When you loaded that sample's solution with VS 2013, did you allow it to "Upgrade VC++ Compiler sand Libraries" for all three projects?"

Yes it prompts me to Upgrade VC++ Compiler and Libraries. I can then build it fine under x64 but not win32. I will have a look at building a new project and be very careful about my includes to see where this problem is occurring.

Note I've updated the PrimitiveBatch tutorial to demonstrate drawing in screen space rather than normalized space.

Thanks for that, works perfectly. I will def use the GetViewPortTransform code to allow the full range of effects.

Just an update - setting up a project following "The basic game loop" and "Adding DirectX Tool Kit" allows me build perfectly fine in 32 and 64 bit, so I think the issues I am having is the older project reffing the legacy DirectX SDK in my include dir's. Thanks