qrli

I've been simply using the A8R8G8B8 and X8R8G8B8 format to create textures for quite some time. These formats are quite commonly supported in recent years, as well as R5G6B5, DXTn, etc.

But I'm just thinking that in theory they're not guaranteed to succeed, and it may need some fallback to other formats. It reminds me of the OpenGL way that you can pass in data in any format and it will convert the data into some internal format so that it will seldom fail.

When I tried to design some fallback mechanism, two issues are in my way:
1) Fallback to what format
TextureLoader.CheckTextureRequirements() seems a nice function to solve this, but the parameters are wrongly set to out parameters instead of ref.

2) How to convert to the fallback format
It's easy to write some code to convert between two or three formats but there're quite many formats out there. And it's possible that these conversion codes will never be executed, so it's a waste of time.

So I'm curious about how you smart guys do it.


Re: Game Technologies: Graphics Texture creation robustness question

Wessam Bahnassi

TextureLoader does this automatically for you. It will choose the best closest format and do the conversion on the fly if the format you ask for isn't supported by the device.




Re: Game Technologies: Graphics Texture creation robustness question

qrli

Yeah. But TextureLoader can only load from file or stream. I have images composed in memory. One walk-around is to write the data to System.Drawing.Bitmap then save it to a MemoryStream, and then use TextureLoader to load it. You know the extra cost here.