direct3d retained mode: upgrading to IDirect3DRM3 from IDirect3DRM

My application uses the old direct3d retained mode system for a 3D GUI and the original interface objects (IDirect3DRM, IDirect3DRMDevice, IDirect3DRMFrame, and the others). I now have a need to use methods in IDirect3DRMMeshBuilder3, but to use the "3" version, the other objects have to be the "3" version. However, to start the process Direct3DRMCreate is used to create a IDirect3DRM object, which used to create other objects. The latest "3" version objects require an IDirect3DRM3 object for thier creation--the problem. Direct3DRMCreate can not create a IDirect3DRM3 object and I don't see a Direct3DRMCreate3 interface. What am I doing wrong?

[699 byte] By [MichaelAThomas] at [2007-12-24]
# 1

Use QueryInterface() on the Direct3DRM object to obtain it's IDirect3DRM3 interface. Something like this:

IDirect3DRM *oldrmobj;
HRESULT hr = Direct3DRMCreate(&oldrmobj);
// check for error here
void *tmp;
hr = oldrmobj->QueryInterface(IID_IDirect3DRM3, &tmp);
// check for error here
IDirect3DRM3 *rmobj = (IDirect3DRM3 *) tmp;
oldrmobj->Release(); // no longer need old interface

RossRidge at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 2

This seems to work--thanks. Also, what about arrays such as used to retrieve and store IDirect3DRMFrame3 objects. All I can find for the frame is the old IDirect3DRMFrameArray -- nothing for the "3" version -- cast the array contents?

Thanks much...

MichaelAThomas at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 3
You have to use QueryInterface() on each frame object to obtain its IDirect3DRMFrame3 interface.
RossRidge at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 4

Sorry, misunderstood the question. There is an interface / container IDirect3DRMFrameArray that can store pointers to IDirect3DRMFrame objects. However, there is not a container for the latest IDirect3DRMFrame3 objects.

Where my current problem is the IDirect3DRMViewport2::Pick(x, y, pickarray) method that requires "pickarray" to be IDirect3DRMPickedArray* array object, which contains pointers to IDirect3DRMFrame objects, not IDirect3DRMFrame3 objects. The scene contains nothing but IDirect3DRMFrame3 objects now.

When I cast the members of the IDirect3DRMPickedArray after the call to Pick, I get results, seemingly valid pointers, but when trying to compare them to my stored frame pointers, they are not valid frame objects.

Also during this "port" I have found that my scene lighting is not the same, which is most likely due to, in part, the light->SetEnableFrame(IDirect3DRMFrame*) call. And again, since I ported my frame objects to "3" and the SetEnableFrame() requests the old verion, the cast I have to make for the code to compile is evidently not going to work.

Any ideas?

MichaelAThomas at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 5

You're confusing interfaces with objects. The types IDirect3DRMFrame and IDirect3DRMFrame3 are not object types and you cannot create objects of these types. They are COM interfaces to an object. The retained mode frame objects created by IDirect3DRM3::CreateFrame() have both IDirect3DRMFrame and IDirect3DRMFrame3 interfaces. One of the fundamental rules of COM is that if you have an interface to an object you can obtain any other interface that the object supports by using QueryInterface(). You cannot use casts to obtain these other interfaces.

RossRidge at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 6
If you want your code to still work next year, get rid of all your Retained mode code and port it to immediate mode. Microsoft has killed Retained Mode in Vista, since barely anyone was using it.
ector at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...
# 7

Are you saying that retained mode won't function in Vista? This may be great -- I'd like to build a my graphics library out of something else.

MichaelAThomas at 2007-10-8 > top of Msdn Tech,Game Technologies: DirectX, XNA, XACT, etc.,Game Technologies: Graphics...