Reputation: 1542
In Direct3d, I'm seeking to inject some custom code at the time of Direct3d vertex or index buffer creation, as well as at the time of Direct3d render calls. I'm hoping that at render time I can somehow map an IDirect3dIndexBuffer9 obtained via IDirect3dDevice9::GetIndices() to the very same index buffer, as Direct3d knows it, that was created earlier via IDirect3dDevice9::CreateIndexBuffer.
My specific question is tricky to answer from the API documentation: If I create an index buffer with IDirect3dDevice9::CreateIndexBuffer() and store a copy of the returned pointer, then at a later point call IDirect3dDevice9::SetIndices using that pointer, will a following call to IDirect3dDevice9::GetIndices() return a pointer value identical to that used in SetIndices(), or is there a chance that the pointer will refer to something that Direct3d knows to be the same buffer, yet have a different pointer value on the client side I'm working on? I could imagine a scenario, for example, where the Direct3d .dll owns a unique, persistent object internally, but creates new lightweight COM wrappers to the client when GetIndices() is called, so that the COM object pointer would be different.
Is there any such guarantee (or warning) in the official Direct3d spec about this? I could code up some tests to see, but I'm worried if the results are positive that I'd code to an accident of the implementation, rather then to the contract of the API.
Upvotes: 0
Views: 133
Reputation: 41067
It should be the same interface pointer, although with Direct3D 9 you should be careful about Get's if using D3DCREATE_PUREDEVICE. These interface pointers are all to things allocated in your user-mode process memory by the Direct3D runtime.
The main places where you can't hang on to pointers with Direct3D are:
Upvotes: 1