Line

JP Bridges

Newcomer
Joined
Jul 19, 2003
Messages
11
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
 
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
 
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
 
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
 
Back
Top