• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

P3D v2 Direct2D

Messages
53
Country
us-hawaii
Good Afternoon Gents,

I am continuing to work on my gauge development skills and C-130 Project. I have figured out how to draw the graphics I need in Direct2D outside of the Sim using SimConnect to supply information (easier test bed for when I'm on the road flying). Now I am taking the step to render the gauge into the sim and I have used the GDI+ example and Naruto-Kuns Direct2D info from the Wiki (Thanks Jon) and I understand them both. That Direct2D example renders to a GDI target which was ingenious on Jon's part in using DirectX 11 technology with the DiectX9 FSX. I am only developing for P3D however, so I am wondering if I can mix the RTT example they provided in the SDK with Direct2D rendering. So far I have found that you can write to a IDXGISurface and pass it to the CreateDxgiSurfaceRenderTarget function similiar to how the GDI example works. Does anyone have any background logic on how this would work? Can I declare a IDXGISurface in a Gauge Decleration so I don't have to mess with the DLL.xml file like the RTT example. Thoughts?

-Matt
USCG HC-130H Pilot
 
If I am understood what you are trying to say, you are drawing a gauge outside FSX and now want to draw it in FSX as well?
 
I was just rendering it outside the sim to make troubleshooting quicker, what I am looking for now is to step away from rendering Direct2D to a GDI HDC and into integrating the Render to Texture Example they have in the SDK. The only problem is that example doesn't interface with the Gauge or Panels structure so I am trying to figure out how to leverage the DX11 Inline Rendering with the Gauge and Panel System. Hopefully that makes sense.
 
You can do pretty much whatever you like. You should be able to initiate the Render to texture stuff from the module_init/module_deinit calls in a gauge. Then when you get the render target view, call GetResource on it to get the ID3D11Texture2D resource. Just remember to release that instance after you have linked it.

Once you have that you can link it with your D2D render target as shown below.

Code:
IDXGISurface *pDxgiSurface = NULL;
 
    hr = m_pOffscreenTexture->QueryInterface(&pDxgiSurface);
 
    if (SUCCEEDED(hr))
    {
        // Create a D2D render target which can draw into our offscreen D3D
        // surface. Given that we use a constant size for the texture, we
        // fix the DPI at 96.
        D2D1_RENDER_TARGET_PROPERTIES props =
            D2D1::RenderTargetProperties(
                D2D1_RENDER_TARGET_TYPE_DEFAULT,
                D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
                96,
                96
                );
 
        SafeRelease(&m_pRenderTarget);
        hr = m_pD2DFactory->CreateDxgiSurfaceRenderTarget(
            pDxgiSurface,
            &props,
            &m_pRenderTarget
            );
        SafeRelease(&pDxgiSurface);
    }

Your gauge probably doesn't even have to be visible (it can be like 1pix by 1pix) and can be on a completely different $vc texture.
 
Last edited:
So where are you getting the Direct2D SDK? What version of Visual Studio is being used for this?

I ask because those are important issues that aren't covered in the wiki entry and they actually do matter.
 
It is part of the June 2010 DX SDK (D2D is built off D3D10.1) and I use VS 2008.
 
From Microsoft:

"Visual Studio 2010 Support The June 2010 DirectX SDK includes support for Visual Studio 2010. The DirectX SDK will continue to support Visual Studio 2008 as well. However, Visual Studio 2005 will no longer be supported."

I think it important that people know that older compilers aren't supported when doing this stuff, and yes people do still use older compilers... especially if the newer ones really don't offer anything of actual value for the increased cost. ;)
 
I have always used the Free VS 2008 Express so as far as im concerned cost shouldn't be of any importance.
 
Back
Top