[RESOLVED] using RenderPlugin for XML CustomDraw element

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
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

[RESOLVED] using RenderPlugin for XML CustomDraw element

Post by Marcin »

As in the topic. Is there a way to invoke RenderPlugin for XML CustomDraw element. Currently the only way I know to draw into XML gauge is using IGaugeCDrawable that enables us to draw GDI content (HDC). Now, I would like to use same DX11 RenderPlugin I use for gauges. Of course I could use CreateDCRenderTarget() but still it implies some limitations and I want to use direct DX11 as it is already done for gauges.

Is this implemented ? If not, how about creating CR for that ? For example in XML we could specify XML parameter Texture=myTexture in the similar way we do in panel.cfg for DX11 gauges.
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: using RenderPlugin for XML CustomDraw element

Post by JB3DG »

You would treat the textures in XML gauges the same way as textures in the panel cfg. The RenderPlugin would still be invoked as long as the texture name matches.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

Re: using RenderPlugin for XML CustomDraw element

Post by Marcin »

Many thanks, I did not know there is already a texture element in XML :) I will try that. I spent the whole weekend trying to figure out how to put shared GPU texture created in another process into GDI context using D2Factory but whatever trick I tried, apparently Microsoft did not allow it and the solution to that is in P3D already. That's great !

BTW, maybe you know how to share ID3D11Texture2D into ID2D1DCRenderTarget ?

CreateDxgiSurfaceRenderTarget cannot be used with D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE and CreateSharedBitmap cannot be used with ID2D1DCRenderTarget, so look like not forseen by DX11...

if not, I will simply skip FSX support and share via CPU. P3D is good enough for me ...
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

Re: using RenderPlugin for XML CustomDraw element

Post by Marcin »

Many thanks Naruto for the hint. Texture element works like charm with RenderPlugin.
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: using RenderPlugin for XML CustomDraw element

Post by JB3DG »

I wouldn't waste my time trying to use D2D with D3D. GDI+ is far easier. You just have to create your own D3D GDI compatible ID3D11Texture2D object, get the IDXGISurface1 object from it, get the HDC from the IDXGISurface1, and then create your Graphics object with that. Then render that texture onto a full screen quad on the render target supplied by the RenderPlugin. Set your blend state right and it will be easy to do a FLIR or radar display with vector overlay.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

Re: using RenderPlugin for XML CustomDraw element

Post by Marcin »

My scenario is bit different. For RenderPlugin I got it all working with you hint. Now I want to use GDI+ to render ID3D11Texture2D into HDC provided by classic C-Gauge or classic IGaugeCDrawable to enable FSX support. What you propose is to render GDI+ into D3D.
JB3DG
Posts: 609
Joined: Mon Jan 09, 2012 6:44 pm

Re: using RenderPlugin for XML CustomDraw element

Post by JB3DG »

D3D in FSX is a bit different. There is a way to use DX11 in FSX (I pioneered that) but unfortunately I can't go into it (proprietary to Milviz). Suffice to say though, it does not use a HDC.
Jonathan Bleeker
Milviz systems dev

Formerly known as Naruto-kun
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

Re: using RenderPlugin for XML CustomDraw element

Post by Marcin »

ok, thx

One last thing. I got the Texture working with RenderPlugin, however it is fine when the Texture element is the front element (z-order), however if I want to use Texture as a background for other XML elements, unfortunately my rendering unlike equivalent CustomDraw element overwrites the whole area and XML z-order is ignored. Any suggestions how to solve that. I do not need any fancy blending, just a background for XML element in the same XML branch.
Marcin
Posts: 20
Joined: Thu May 08, 2014 3:09 pm

Re: using RenderPlugin for XML CustomDraw element

Post by Marcin »

ok, got it working

TEXTURES_BELOW_PANEL = 1
Locked