[RESOLVED] PDK v4.1 header issue (IWindowV410, ICameraSystemV410, etc)

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Locked
adiemus
Posts: 120
Joined: Fri Mar 16, 2012 4:19 am
Contact:

[RESOLVED] PDK v4.1 header issue (IWindowV410, ICameraSystemV410, etc)

Post by adiemus »

The v4.1 PDK added some new functionality I wanted to try, so I switched our existing code to use the new headers. This worked fine (while my code was still referencing the V400 stuff) but as soon as I started trying to use IWindowV410 or ICameraSystemV410 it all refused to compile, seemingly because of inconsistent updates in the PDK headers.

The simplest place to see this is in IWindowPluginSystem.h in the declaration for IWindowV410::GetCameraSystem() which is still defined as returning an ICameraSystemV400* rather than an ICameraSystemV410*. There are several similar issues.

Rather than listing all the compile errors, I'll just post a diff of the changes I had to make to get things to work. I'm curious to know if these are legit or if I've made a mistake somewhere. (Quite possible, I can't claim to really understand COM)
adiemus
Posts: 120
Joined: Fri Mar 16, 2012 4:19 am
Contact:

Re: PDK v4.1 header issue (IWindowV410, ICameraSystemV410, etc)

Post by adiemus »

Looks like IBaseObjectV410 has the same issue.
adiemus
Posts: 120
Joined: Fri Mar 16, 2012 4:19 am
Contact:

Re: PDK v4.1 header issue (IWindowV410, ICameraSystemV410, etc)

Post by adiemus »

Having read more about COM versioning, I think now that the headers are fine, it was me that was mistaken.

For anyone confused as I was how you'd use IBaseObjectV410, for example, when ISimObjectManagerV410::GetUserObject() takes a **IBaseObjectV400 argument, you have to get the IBaseObjectV400 first, then query it for the interface to the V410. Something like (note, this is simplified code with error checking omitted):
CComPtr<P3D::IBaseObjectV400> pObjectV400 = nullptr;
spSimObjectManager->GetUserObject(&pObjectV400);

CComPtr<P3D::IBaseObjectV410> pObjectV410 = nullptr;
pObjectV400->QueryInterface(P3D::IID_IBaseObjectV410, (void**)&pObjectV410);
Ugly, yes, but that's COM for you.
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: PDK v4.1 header issue (IWindowV410, ICameraSystemV410, etc)

Post by Clifton Crane »

Hi adiemus,

That is the correct approach. Existing functions will continue to take in or return the older interface to maintain backwards compatibility with previous versions of Prepar3D.

Thanks!
Clifton Crane
Prepar3D® Software Engineer Sr.
Locked