Welcome to Atalasoft Community Sign in | Help

MD3DM Direct3D Texturing Bug

I have been playing around at home with coding for Windows Mobile 5, and while poking around, I was excited to see that there is an implementation of Direct3D.  I haven't done any DirectX programming since 1998 or so and I thought it'd be fun to pick it up and see what they've done with it and to also see what my Cingular 8525 can do.

I downloaded sample code from Microsoft and immediately found out that the texturing demo crashes with an InvalidCallException in Surface.UnlockRectangle.  This is a result of using the TextureLoader class, which is the only public API for turning images into textures.  This is pretty bad, I think and very disappointing
 as well, but I'm a stubborn cuss and I decided to see if I could construct a functioning Texture on my own.  That turned out to be straight forward, except for one detail.  I had to figure out which texture format is suitable for my device.

I wrote a little routine that tries them all out and only keeps the working ones.  For the 8525, you can render textures from 32 bit bgra and 16 bit rgb (5-6-5).  Just 2?  That's disappointing too.  Anyhow, once I figured that out, I  was able to create a synthetic Texture and get the demo working.  Nice.

Because that's possible, it means that I can write a converter to go from Bitmap objects into Texture objects.  It involves some unsafe code (this is for performance reasons and ease of coding, really) and a lot of bit twiddling, but it works, and I'm offering to those who are interested in using it.

In the original Microsoft sample code, this is the line that fails:

            texture = TextureLoader.FromStream(dev,
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "Texture.Content.Banana.bmp"));


you can now replace it with this code:

            ReliableTextureLoader loader = new ReliableTextureLoader(dev);
            texture = loader.FromStream(loader.GetBestFormat(),
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                "Texture.Content.Banana.bmp"), PixelFormat.Format24bppRgb);
 

The entire class should be downloadable here. You can drop this file into your managed Direct3D application and use it pretty much wherever you'd use TextureLoader.  I've written it for the sole purpose of getting textures working on my phone, but it's extensible and should be capable of growing into the future.

 In reflection, this is a very empowering exercise because of the immediate problems I found in Direct3D.  It's frustrating to have so much potential and to hit a roadblock right away, but it's great to be able to build a functioning workaround.  It took me 4 hours while I rode the learning curve, but I'm still pretty happy with the outcome.  Unfortunately, this experience is also all too familiar.  10 years ago I was working at a company that was writing a high speed 3D engine and we had a box of 3D cards that were basically bricks because the drivers made them unusable in any reasonable way, or our own software renderers were faster than the card (!!).  I've read a little but about the D3D driver for this device and it hasn't been really complimentary.

 Hopefully this post might turn a few heads and maybe Microsoft or HTC (the phone manufacturer) will publish an updated driver before the device goes obsolete.

Published Saturday, January 20, 2007 11:38 PM by Steve Hawley

Comments

Tuesday, February 06, 2007 2:57 PM by DotNetKicks.com

# Direct3D Texturing Bug in HTC devices

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Monday, September 03, 2007 5:26 PM by rapbbit

# re: MD3DM Direct3D Texturing Bug

Hello,

  I am really want to download your code.

But the server disable now.Can you send me

the code to products@pdafun.net ?

Thanks.

Monday, November 12, 2007 10:23 AM by d95danb

# re: MD3DM Direct3D Texturing Bug

This sounds very interesting since I experience a similar problem with the TextureLoader class. Would you mind sending it to me (d95danb1@hotmail.com) or making it availible somewhere else since the current location is unavailable.

Thanks.

Friday, March 14, 2008 10:05 AM by Rolf

# re: MD3DM Direct3D Texturing Bug

Hi. Now that was a very helpful post for me. It seems that every MD3DM driver really behaves differently and it's hard to find a common denominator. I managed to cope with the "D3DM TI3D Driver" (HTC 3300, Qtek S200 ...) and the "D3DMXSC50PB.DLL" (LOOX N520 ...). The problem described in this blog entry I've only seen together with the "Mega Ultra BVS. V2.0" installed on the Treo 750 and some of the other HTC phone types.

Would you mind sending the ReliableTextureLoader class also to me (rolf.kistler@hslu.ch). That would help me a lot. Many thanks!

Another helpful link concerning diagnostics of Mobile D3D Applications (for me) was: http://blogs.msdn.com/markprenticems/archive/2006/03/10/547983.aspx

Monday, July 07, 2008 7:45 PM by Lipitor.

# Side effects of generic lipitor.

Muscle loss due to lipitor. Lipitor side effects. Lipitor. Nicain and lipitor.

Sunday, May 31, 2009 10:01 PM by Bronchitis and amoxicillin.

# Amoxicillin.

Can greyhounds take amoxicillin. Buy amoxicillin online cheap amoxicillin. Amoxicillin trihydrate. Amoxicillin acne.

Monday, July 13, 2009 11:50 AM by Steve's Tech Talk

# Try Not to Hate Your Customers

A few years ago Atalasoft bought me a Cingular 8525, a phone made by HTC running Windows Mobile 5. 

Anonymous comments are disabled