Posted By: scobleizer | Mar 16th, 2006 @ 8:10 PM | 66,989 Views | 13 Comments
Usually we have Microsoft employees on here, but Mike Hall met a talented MVP, Chris Muench, a Mobile and Embedded MVP. Here he shows how to write a managed Direct3D application for Windows Mobile devices and thought it deserved being on Channel 9.
Media Downloads:
Rating:
0
0
Khamul
Khamul
Death by Escape Key
Again with the many videos in the short time period - you made me write a download manager in C#!

No, I'm not going to use some Commercial, ad ridden s*** off Download.com.
Minh
Minh
WOOH! WOOH!
What percentage of PocketPC supports DirectX?
What's the expected growth of this segment?
I remember doing this stuff at last year's MEDC. I even got to talk to Chris after his session. Fun stuff. It made me want to get a Dell Axim when Window Mobile came out(We got a few DX apps to work on it at my office using the beta for CF  2.0, but I haven't gotten the damn thing yet).
bonk
bonk
Ich bin der Wurstfachverkäuferin !
If you want to to try that game, it is called Pocket-Jongg 3D and it looks like there is a free demo version of it. You can download it from handango.

EDIT: hm, looks like that game will not work on a HTC Universal. It throws an Microsoft.WindowsMobile.DirectX.DriverUnsupportedException.

[C]
Khamul wrote:
Again with the many videos in the short time period - you made me write a download manager in C#!

No, I'm not going to use some Commercial, ad ridden s*** off Download.com.


Actually, CNet has a policy stating that no downloads they host will have ad-ware in it. There's no policy against annoying shareware, however Tongue Out
PerfectPhase
PerfectPhase
"This is not war, this is pest control!" - Dalek to Cyberman
Khamul wrote:
Again with the many videos in the short time period - you made me write a download manager in C#!

No, I'm not going to use some Commercial, ad ridden s*** off Download.com.


http://www.freedownloadmanager.org/

No ads, great bit of software.

Stephen.
AQ
AQ
One does not thank logic
I am so loving developing games on the windows mobile platform with managed Mobile DirectX. The integration with VS2005 and the device emulator is fast and some of the new debug tools are handy. 

There are just a couple things to keep in mind because of the reduced functionality on the mobile platform. Obvi, all the shaders and effects stuff in the programmable pipeline isn't included, but the next generation of mobile GPU's will be almost pc-quality..

I am still using OnPaint to render my scenes, like the code in this demo. There was a lot of debate about this in managed DirectX for winforms and Tom Miller posted a 'perfect' render loop using interop to hook into the windows message pump. Is there a perfect render loop that can be implemented in managed mobile DirectX development?

Personally I think performance is good enough using the builtin events and it's better to optimize the game code. But any increase in performance is welcome in pushing the edge Smiley
AQ
AQ
One does not thank logic
bonk wrote:
If you want to to try that game, it is called Pocket-Jongg 3D and it looks like there is a free demo version of it. You can download it from handango.

EDIT: hm, looks like that game will not work on a HTC Universal. It throws an Microsoft.WindowsMobile.DirectX.DriverUnsupportedException.




It helps to identify the D3DM driver and configure accordingly. On the HTC, a software reference driver cripples D3DM framerates Mad

LINK:
http://blogs.msdn.com/markprenticems/archive/2006/03/10/547983.aspx

(This is WinCE-compatible Win32 unmanaged C/C++ code but hopefully there a similar way to do it in WinCE managed C#.)

"Tom Miller posted a 'perfect' render loop" - I didn't see his render loop, but for games a simple yet effective loop that I use is this (pseudo-code):


while()
{
   PeekMessage(&msg)
   TranslateMessage(&msg)
   DispatchMessage(&msg)
   DoSomethingElseWithMessage(&msg)
   Clear(&msg)

   DoGameLoop()

   Sleep(0) // throw in a Sleep(0) or Sleep(1) if having timing issues
}

That is the basis of it.  You may want to loop to process all messages in the queue before calling DoGameLoop.  And you may want to only call DoGameLoop every 1/60 of a second or something (use QueryPerformanceCounter for timing).  But yeah basically that is it.

Ignore WM_PAINT by simply returning 0 and only draw the backbuffer to the screen in DoGameLoop and WM_ERASEBKGND messages (return non-zero for WM_ERASEBKGND).

Don't actually write game code in WNDPROC, just build a queue of received input and process the queue in DoGameLoop.

It is that simple and will speed up your game whether you are using GDI or Direct3D.


If graphics is another culprit of main slowdown, then figure out whether your platform supports accelerated 2d and/or 3d rendering.  If no 3d acceleration but yes 2d acceleration, then use 2d acceleration to make a faster 3d game (or just write a 2d game).  But to do that you'll need direct write access to video memory, which as far as I know the only 2d graphics API that gets you that is DirectDraw.  Though I don't know if DirectDraw exists for WinCE.

Otherwise you are stuck with GDI/GDI+ (only GDI+ for C#).  And if you use GDI and need pixel access use CreateDIBSection to create your backbuffer HDC's HBITMAP.
Microsoft Communities