JP Bridges Posted September 5, 2003 Posted September 5, 2003 Folks, Has anyody had any experience using Microsoft::DirectX::Direct3D::Line. I'm using it and drawing lines but when the D3D Device gets reset (for example when you resize the window) the Device enters an invalid state. It basically says that I must uninitialise any state blocks associated with the device before it can be reset. Now this only happens when I use Line... so I guess it's talking about state blocks associated with the line class. Here is (in a roundabout way) what I'm doing. 1. Create Device... 2. On a paint event... a) Line * pLine = new Line(device); b) Set Line States (width, etc). c) Device->BeginScene d) Line->Begin e) Line->Draw f) Line->End g) Device->EndScene h) Device->Present Now as stated this works great, until the device is reset, then it grumbles - pretty fatally. Am I using Line correctly? Does anybody know why I get errors? JP Quote
*Experts* Nerseus Posted September 8, 2003 *Experts* Posted September 8, 2003 What does dbmon report as the error? I used to see other errors when resetting a device, usually my not releasing certain resources like I should. I haven't done much with the render state blocks, but I wonder if you have to call Dispose when you're done with them? Is this managed C++ DX9 by the way? -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
JP Bridges Posted September 8, 2003 Author Posted September 8, 2003 Thanks Nerseus, I called Dispose explicitly and it worked like a charm. Funny though, my instance of Line was a local variable so I would have thought that Dispose would have been called automatically when it went out of scope. I guess it took a while for the garbage collection to kick in. JP Quote
*Experts* Nerseus Posted September 9, 2003 *Experts* Posted September 9, 2003 I guess it took a while for the garbage collection to kick in Exactly - the GC only runs as needed. That works great most of the time, unless the object holds onto resources. Even .NET managed objects hold resources, such as the Graphics object (part of GDI+). It also wants an explicit call to Dispose when through with it (not in a Paint Event handler, where the .NET framework does the creating/releasing). It's hard to know when you NEED to call Dispose vs. just want to. You can always call Dispose if you're in doubt, but it's so sloppy (sorta). Usually the docs will let you know when you *must* call it. Glad you got it working, by the way :) -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.