XNA Creators Club Online
Page 2 of 2 (29 items) < Previous 1 2
Sort Posts: Previous Next

Capture the screen

Last post 05-30-2008 5:36 AM by jan1024188. 28 replies.
  • 05-02-2008 12:30 PM In reply to

    Re: Capture the screen

    The problem is in your CreateDevice function. You aren't actually changing pd3dDevice there. To do that you would need something like:

    HRESULT CALLBACK CreateDevice( IDirect3DDevice9** pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext )
    {
    HRESULT hr;
    *pd3dDevice = DXUTGetD3D9Device(); //hopeless
    V_RETURN( (*pd3dDevice)->CreateVertexDeclaration( MESHVERTEX::Decl, &g_pMeshDecl ) );
    V_RETURN( (*pd3dDevice)->CreateVertexDeclaration( SHADOWVERTEX::Decl, &g_pShadowDecl ) );
    V_RETURN( (*pd3dDevice)->CreateVertexDeclaration( POSTPROCVERTEX::Decl, &g_pPProcDecl ) );
    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( *pd3dDevice ) );
    g_SkyboxOne.OnCreateDevice( *pd3dDevice, 50, g_SkyboxModelOne, g_EffectSkybox );
    blah blah blah
    }

    And call it like this:

    CreateDevice(&pd3dDevice,....); // note that we pass the address of our pointer.

     

  • 05-02-2008 12:36 PM In reply to

    Re: Capture the screen

    Wait a minute... That is a callback function, so you probably can't change the signature like that.

    You would need to define a global IDirect3DDevice9 pointer and copy the pd3dDevice value to it in that function. Something like:

    IDirect3DDevice9* g_pd3dDevice = NULL;

    HRESULT CALLBACK CreateDevice( IDirect3DDevice9* pd3dDevice,...);

    {
    ...
    g_pd3dDevice = pd3dDevice;
    ...

    }

    And then use g_pd3dDevice elsewhere in your code. (Which is probably what you intended to do when you originally created the g_pd3dDevice variable.)

     

  • 05-02-2008 12:47 PM In reply to

    Re: Capture the screen

    Or, better yet, don't create a global pointer because you don't need it. Just call DXUTGetD3D9Device whereever you need the pointer. For example:

    createScreenshot(DXUTGetD3D9Device());

    That will ensure that you get a pointer and eliminate any confusion with local/global variables, etc.

    You definitely don't need to call DXUTGetD3D9Device inside the CreateDevice callback, since the framework passes the device pointer in the first parameter.

     

  • 05-30-2008 5:36 AM In reply to

    Re: Capture the screen


    David Hunt:

    Or, better yet, don't create a global pointer because you don't need it. Just call DXUTGetD3D9Device whereever you need the pointer. For example:

    createScreenshot(DXUTGetD3D9Device());

    That will ensure that you get a pointer and eliminate any confusion with local/global variables, etc.

    You definitely don't need to call DXUTGetD3D9Device inside the CreateDevice callback, since the framework passes the device pointer in the first parameter.

     

    Now I get

    error C2448: 'makeScreenshot' : function-style initializer appears to be a function definitio

     error C2660: 'makeScreenshot' : function does not take 1 argument

     

     

Page 2 of 2 (29 items) < Previous 1 2 Previous Next