Is it possible to create and use a subclass of IDirect3DDevice9
? It would be very convenient for my code to do so, but I see that a device pointer is given as an out parameter from IDirect3D9::CreateDevice()
, and I can't just tell it to make an instance of my subclass instead.
I'd like to be able to do this so that other code that uses an IDirect3DDevice9
won't have to change when I want it use a subclass of the device with expanded functionality. Specifically, the subclass needs to read the device's render state settings and update shader variables to match whenever any variant of IDirect3DDevice9::Draw()
is called, before the actual drawing is done. Again, I don't want other code using a d3d device to change, because I want it to be able to use either a regular device or my augmented one.
Is it possible to create an instance of the subclass using an instance of the base class? If so, will that cause any problems such as Direct3D not set up to use the subclass instance, or multiple device instances in memory and thus having to share gfx card resources, etc.? Or should I just think of another way around this without using a subclass?