Yep, it never fails. Just when I think things are going good, programming wise. I get slammed with another unforeseen problem or dellema. This time it's a problem. With DirectX. Again.
You wanna talk about strange behavior, lets talk about strange behavior. I was playing around with ways to simplify directx down to an aboslute minimum. What I did was create a class library. And added a bunch of modules, and in those modules I added some publicly available methods such as InitGraphics, ShutdownGraphics, EnableLighting etc etc.
Now all of the variables like the D3D Device, and present parameters etc are module level varibles that are not visible to outside apps. They are declared friend so only the Class library can see them. Although I do provide methods for accessing those variables indirectly through some methods, GetD3DDevice for example is one of those methods.
But it seems when I create an application that references this class library and calls the InitGraphics method but then tries to get the value of a render state on that device like so ...
InitGraphics(Me, True) ' True means windowed mode
' get the Lighting render state property and show it
msgbox(GetD3DDevice.RenderState.Lighting.ToString)
I keep getting a InvalidCallException being thrown when I try to retrieve the Lighting render state!?! I get this exception when I try to access any of the render state properties, or other specific properties on the device including things like the Material property.
I don't get this error when I call the EnableLighting (sets the Lighting render state property) method but I do get a InvalidCallException being thrown when I try to retrieve the value of one of the render state properties on this device!
Now here is the thing. i have also tried converting the modules in the class library into classes so that my application has to create an object in order to work with the methods. but I still get the same exception being thrown! What's up with that?
You wanna know what the really odd thing is. I have never ever had an InvalidCallException thrown before until of course I installed the new DirectX sdk December 2004 a few days ago! This is what I suspect is causing me my problems. Either that or it's some sort of threading issue. I doubt it's a threading issue simply because my app does not spawn any threads.
I have started a thread over at the VBGamer website in the hopes of resolving this issue.