Contrast Posted January 25, 2003 Posted January 25, 2003 I'm trying to piece together a bitmap and then make a nondynamic texture from it. I use the static method Texture.FromBitmap() in the Microsoft.DirectX.Direct3D namespace, but I get an IllegalArgumentException regardless of the arguments I feed it. My code looks like this: Bitmap bitmap = new Bitmap(blockWidth, blockHeight, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Graphics graphics = Graphics.FromImage(bitmap); (... draw with graphics object ...) Texture texture = Texture.FromBitmap(Game.device, bitmap, 0, Pool.Default); The last line throws the exception. I've tried several different Usage enumerations (3rd argument), and three or four PixelFormats for the Bitmap object, but I can't get rid of the exception. The worst part is that the exception doesn't explicitly tell me what's wrong, and neither does MSDN and it's 'preliminary documentation.' Can anybody point me in the right direction please? Thanks in advance, Contrast Quote
*Experts* Nerseus Posted January 26, 2003 *Experts* Posted January 26, 2003 I'm not at a machine that has DX installed right now but I can help (hopefully)! Look in the folder DXSDK\bin\dxutils for a program called dbmon.exe (I may have dxutils and bin swapped in the actual path). Run this program before you run your DX9 app. It's a console app that picks up a bunch of messages from DX9 - some informational, but a lot of error information, too. It should be able to tell you what's wrong. Especially with textures, DX9 is very particular about the pool a texture is located in as well as the usages defined when you're creating or copying textures. Hopefully DBMon will tell you what's wrong (like you can't use the Default pool for textures loaded from bitmaps or something like that). Alternatively, if you really want a lot of info spewed out, turn on managed debugging (go to the Project Properties to turn this on). If you look in the Output window (ctrl-alt-o) you'll see the *real* DX9 errors get spit out, along with a ton of other information. If you still can't get it working by tomorrow, let us know. I'll try and create a test project here to see what I get. -ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Contrast Posted January 26, 2003 Author Posted January 26, 2003 Thanks a lot, I turned on that unmanaged debugging flag and was provided immediate insight, after MSDN didn't give me a thing (of course that's partly due to the SQL Server worm slowing us all down). It turns out that it creates the texture surface and then draws the image onto it, not vice-versa, so that the texture has to either be dynamic or be in a different pool. Since my driver apparently doesn't support dynamic textures, I switched it to the managed pool and it works like a charm. Thanks a bunch. Quote
*Experts* Nerseus Posted January 26, 2003 *Experts* Posted January 26, 2003 For future reference, you may have finer control of where textures (and vertex buffers, and more) go when using different pools, but for just starting with .NET I'd go with the Managed pool for pretty much everything. In the managed pool, you don't have to worry about freeing resources when the device is lost or reset. By using the Default pool you'll have to sync up the device's reset so that all of your resources are freed and re-created at that time. Also, I noticed that turning on the managed debugging added a TON of information whereas dbmon only spits out messages from DirectX. If you have a not-so-fast machine like me then it may be better to just use dbmon. Glad you got the problem worked out though :) -nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
apanjocko Posted September 3, 2003 Posted September 3, 2003 do you mean turn on the UnManaged debugging in the Project Properties/Debugging menu? Quote
*Experts* Nerseus Posted September 3, 2003 *Experts* Posted September 3, 2003 apanjocko, this thread is REALLY old. But yes, if you have DX SDK installed with the Debug runtime, you can turn on the UnManaged Debugging to see a TON of info (not just on DX, but from all the System DLLs as well). -Ner Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.