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

adiemus
Posts: 116
Joined: Fri Mar 16, 2012 4:19 am
Contact:

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

Postby adiemus » Wed Jan 10, 2018 11:23 pm

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: 116
Joined: Fri Mar 16, 2012 4:19 am
Contact:

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

Postby adiemus » Wed Jan 10, 2018 11:56 pm

Looks like IBaseObjectV410 has the same issue.

adiemus
Posts: 116
Joined: Fri Mar 16, 2012 4:19 am
Contact:

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

Postby adiemus » Thu Jan 11, 2018 6:16 am

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: 883
Joined: Tue Sep 25, 2012 2:34 pm

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

Postby Clifton Crane » Mon Jan 15, 2018 3:37 pm

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


Return to “Software Development Kit (SDK) Questions”

Who is online

Users browsing this forum: No registered users and 3 guests