Multiple LPDIRECT3D9 objects

Started by
3 comments, last by amtri 16 years, 11 months ago
Hello, I'm in the process of writing library functions that interface with Direct3D. However, it is possible that the user of these libraries has already instanced a Direct3D9 interface, and even created devices and set render states in it. Given that, I was wondering whether somebody could help me with some questions: 1) If my user has already created a Direct3D9 interface and is already controlling the screen with a LPDIRECT3DDEVICE9 object, is there any way I can find that out? 2) If that's the case, can I query Windows for this information? How? 3) If it's not possible to get this information, what are the implications of having multiple LPDIRECT3D9 and LPDIRECT3DDEVICE9 objects controlling the same device? Thanks.
Advertisement
To the best of my knowledge, there's no way to get the current device, or to determine if one has been created.
I don't really know what will happen if you try to create two devices on one window, I suspect the second one will just fail at the CreateDevice() call.

Surely if a user is using your library, it's their own fault if they've already got a device?
Actually, this is quite possible. They may already have some graphics going on, but may want to use my library for some very specific action they don't want to deal with.

A good example would be they are writing a game but all they want from my library would be the ability to create a person with all its attributes to add to the game. In that case, I need to *fit in* their environment, rather than force one upon them.

At the same time, them may prefer to let me deal with ALL graphics issues. In this case, I would control all Direct3D objects from the start.

Thanks.
So you need two varieties of init code. One which will create a device for them, and one which will take their device, and store it locally. The rest of the code just uses the device pointer, wherever it happened to come from.
Namethatnobodyelsetook: thanks! I was wondering whether I would have to have them pass me the pointers, or whether I could just query Windows for it.

Looks like they have to pass it over to me :-(

Thanks again.

This topic is closed to new replies.

Advertisement