Extension Casting D3DX11Device from os_get_info into valid data type

Discussion in 'Programming' started by Sammi3, Sep 9, 2019.

Tags:
  1. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    163
    I wanted to cast the D3DX11Device and D3DX11Context from the map provided by os_get_info into the correct type using the correct formating. On the C++ side, I currently have my dll setup as follows:

    Code:
    fn_export double Init(void* dx11Device, void* dx11Context, void* windowHwnd) {
    
        //Cast void pointers to correct types
        g_pd3dDevice = (ID3D11Device*)dx11Device;
        g_pd3dDeviceContext = (ID3D11DeviceContext*)dx11Context;
        HWND hwnd = (HWND)windowHwnd;
    
    }
    I was under the impression that I had to cast them as the data type and not as a pointer to their datatype as I did the HWND but that doesn't seem to work, I can only cast them as a pointer to their data type. Any ideas on how I should approach this?

    Kind thanks,
    Sammi3.
     
  2. Binsk

    Binsk Member

    Joined:
    Jun 22, 2016
    Posts:
    583
    No, GameMaker gives you a pointer so the data you will get in the DLL is a pointer. HWNDs are kind of special, look up their definition and you'll see what I mean.

    If you don't want to use the pointer in the DLL just deference it and store the result in a variable. Other than that, I'm not sure what your question is?
     
  3. Sammi3

    Sammi3 Member

    Joined:
    Jun 20, 2016
    Posts:
    163
    I solved this. All I had to do was cast the void pointers to a pointer of type ID3D11Device for the d3d11 device and ID3D11DeviceContext for the d3d11 context and use them as such.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice