Talk:DirectX on Windows Phone: 2D Game Example using DirectX Toolkit

From Nokia Developer Wiki
Jump to: navigation, search


Kleimola - Few minor notes

First of all, thank you very much for this awesome example and the excellent walkthrough!

For those trying to type in the code in the final version of VS Express for Windows Phone (Windows Phone SDK 8.0) note that some of the pre-generated code in the template differs a bit and you may run into 'EventRegistrationToken' : ambiguous symbol errors. Check the provided .zip file for correct includes and using namespace -directives. Eg. BasicTimer.h has #include <wrl.h> and should have #include <wrl/client.h> instead.

And those trying to compile and run the provided .zip in the emulator, note that the project configuration properties for the emulator is incomplete (check with the ARM or device configurations) so add the missing libs and include directories. In addition the myfont.spritefont file lacks the Content - Yes in it's properties (explained in the walktrough). Otherwise you'll get very diffusing errors about invalid parameter and Msvcr110d.dll since the file is not included in the generated XAP file.

kleimola 23:57, 12 December 2012 (EET)

PaddlePop - Problem with linker

Thank you for the great walk through

I am working through the first half, however I am having a problem compiling at the end of part 3. After working my way through the errors I can understand, I keep getting a linking error:

"PhoneDirect3DApp1.obj : error LNK2019: unresolved external symbol "private: __cdecl Renderer::~Renderer(void)" (??1Renderer@@A$AAA@XZ) referenced in function "public: virtual unsigned long __stdcall Renderer::[Platform::Object]::__abi_Release(void)" (?__abi_Release@?QObject@Platform@@Renderer@@U$AAGKXZ)"

It is my understanding I am having a linking problem and have double checked the "Input" libraries in linker and it only contains d3d11.lib, dxguid.lib, XAudio2.lib. I am new to Windows 8 Phone and DirectX and have been trawling the internet from some time now to no avail.

Any help would be appreciated

PaddlePop 08:02, 4 April 2013 (EEST)

Hamishwillee - The author may or may not be watching!

If you don't get a response, you might want to ask on the discussion boards.

hamishwillee 09:08, 17 April 2013 (EEST)

Jumantyn -


And first of all, sorry for the late response.

This article was made with the RC version of the SDK and things have probably changed between it and the retail version of the SDK. I have been meaning to go thtough the article again with the retail SDK but unfortunately I haven't had the time for that yet.

I also can't tell what the problem is just from the errror message you posted since it's been quite a while since I've done anything with DirectX on WP myself too. So I would suggest asking at the discussion boards like Hamish suggested.

jumantyn 10:14, 17 April 2013 (EEST)

IRperson - Renderer Destructor


@PaddlePop: The Destructor in Renderer.cpp is causing this problem, if you comment it out or write an empty destructor (Renderer::~Renderer() {}) into your Renderer.cpp file, it will build successfully.

iRperson (talk) 18:07, 31 August 2013 (EEST)

TomiLEEjones - a little mistake that can cause you much trouble

The ball texture is placed in the "Assets" folder so the path passed to CreateDDSTextureFromFile function should be "Assets/ball.dds", not just "ball.dds". I got very misleading errors because of that (about msvc110d.dll) and spent almost 3 days brainstorming something caused by such a tiny typo by the author.

Great tutorial nonetheless!.

tomiLEEjones (talk) 00:46, 17 September 2013 (EEST)

(I will try to finish all the steps tomorrow, then i will update the article and the attached files)

Hamishwillee - @TomiLEEjones - can you fix it?

Hi TomiLEEjones

Would it be possible to update the article and attached file File:Example2DGame.zip?

We could then update this article and remove the "ArticleNeedsUpdate" warning up the top - knowing it works! Of course I could try this, but I'm not an expert in this domain and I don't have it already set up as you do.

Regards Hamish

PS Even if you can't make this update, thank for taking the time to post the note.

hamishwillee (talk) 03:21, 19 September 2013 (EEST)

Hamishwillee - Thanks TomiLEEjones

Much appreciated!

hamishwillee (talk) 03:39, 19 September 2013 (EEST)

TomiLEEjones - @Hamishwillee

How do i upload an attachment? I got the source .zipped :)

Hamishwillee - This way ...

Go to File:Example2DGame.zip and select link "Upload a new version of this file". Can you please also tell me what devices you tested this against - I'll add that to the articlemetadata.

Once you've done this I believe all questions are addressed and I can delete these comments - correct?

Thanks very much for this!

PS I am away next week, but will check back in the week after :-)

hamishwillee (talk) 03:48, 20 September 2013 (EEST)

TomiLEEjones - @Hamishwillee

Thank You, i uploaded the source code. I tested it against Windows Phone Emulator & my nokia lumia 520. That should basically cover all cases. I think we can now savely remove the comments, yes. Have a nice one :)

KevinStubbs - Error in code sample on website

Under 2D Game Example Part 2, Render.h has the private member defined as Ball* m_ball, but examples from Render.cpp use ball (without the m_)

This has been great for getting started on Windows Phone 8 development :)

KevinStubbs (talk) 11:18, 22 September 2013 (EEST)

KevinStubbs - Nothing was rendered when m_spriteBatch->Begin, Draw, and End were executed before OMSetRenderTargets

Sorry for another comment, but in case people don't see anything rendered, I would try executing these 3 lines:

m_spriteBatch->Begin(SpriteSortMode_Deferred, states.NonPremultiplied()); m_Ball->Draw(m_spriteBatch.get()); m_spriteBatch->End();

After m_d3dContext->OMSetRenderTargets and not before. Not sure if this is normal behavior or not. This blog post instructs you to execute these lines after everything else in ::Render(). http://www.catalinzima.com/2012/11/getting-started-with-direct3d-on-windows-phone-8-for-2d-game-development/

KevinStubbs (talk) 11:52, 22 September 2013 (EEST)

TomiLEEjones @ KevinStubbs

1. Regarding the m_spriteBatch->Begin() call before OMSSetRenderTargets it should not make much difference (in my case it doesn't), but i will edit the article for convenience. 2. Thanks for the good eye regarding the " m_ball ". : )

Hamishwillee - Thanks guys

Agreed, thanks for removing the warning and all the other fixes!

Tomi - just FYI, this is how other's see you: https://developer.nokia.com/Profile/?u=tomiLEEjones - it would be great if you could edit your profile and make it public (there is a privacy and security link for this in your profile).



hamishwillee (talk) 03:06, 30 September 2013 (EEST)

Hamishwillee - Thanks for the profile update Tom

What a great place to live!

hamishwillee (talk) 08:09, 3 October 2013 (EEST)

Imagnity - Spritefont Error - cannot find string

m_spriteFont = unique_ptr<SpriteFont>(new SpriteFont(m_d3dDevice.Get(), L"myfont.spritefont"));

Throws the stated error. WP8 development is not so hard compare to setting up the damn thing. It is so frustrating. Could never got Example2DGame.zip running. There's no error in build time, but when it starts to load (Loading...), and then boom..mr watson gone crazy! I updated to VS Update 3 and then recently 4 thinking that it would resolve but no, it didn't. I tried several times before and then yesterday for 7 hours straight doing a lot of research and all and then gave up. Not worth the time. Microsoft, at least have the development setup easier. It is not 90's when we used to install a specific driver to code for a specific graphics api. Never took an hour to setup and running projects built on libgdx, SprikeKit, Cocos2d-x, and Shiva Engine. Cocos2d-x WP8 sample needs just a click to build and run. And no execuses please. Save them for newbies, you may get with it.

By the way, my anger is not pointed to you jumantyn. You did a good job but unfortunately I couldn't get it to work. I saw this almost a year ago and then I tried, gave up, tried, gave up. Thanks to DirectXTK WP8 simple sample. Was blind not to see it before. Finally I can start.

Imagnity (talk) 15:41, 26 November 2013 (EET)