XNA Creators Club Online
Page 1 of 1 (3 items)
Sort Posts: Previous Next

Very advanced, screenshot at startup, DX10

Last post 10/17/2009 12:44 PM by JonRambo. 2 replies.
  • 10/11/2009 8:11 PM

    Very advanced, screenshot at startup, DX10

    Thank you for reading my post,

    Just getting to know the DX10 SDK;    My first project is an intro to a game dubbed "The Epic of Gilgamesh".

    Id like to make a short intro. I would like the players desktop to open up to theatrical sounds and lights of the game title emerging from there desktop.

    I'm sure everyone will be doing it once I do it first(or second who knows, its probably been done).

    I need advice on how to capture the desktop as one of the first things the application does at startup, hopefully before any devices are initialized that could cause screen flicker.

    My device initialize method cut and paste directly from a DX10 example:

    HRESULT DX10::InitDevice()  
    {  
        HRESULT hr = S_OK;  
     
        RECT rc;  
        GetClientRect( g_hWnd, &rc );  
        UINT width = rc.right - rc.left;  
        UINT height = rc.bottom - rc.top;  
        UINT createDeviceFlags = 0;
    #ifdef _DEBUG  
        createDeviceFlags |= D3D10_CREATE_DEVICE_DEBUG;
    #endif  
     
        D3D10_DRIVER_TYPE driverTypes[] =  
        {  
            D3D10_DRIVER_TYPE_HARDWARE,  
            D3D10_DRIVER_TYPE_REFERENCE,  
        };  
        UINT numDriverTypes = sizeof( driverTypes ) / sizeof( driverTypes[0] );  
     
        DXGI_SWAP_CHAIN_DESC sd;  
        ZeroMemory( &sd, sizeof( sd ) );  
        sd.BufferCount = 1;  
        sd.BufferDesc.Width = width;  
        sd.BufferDesc.Height = height;  
        sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;  
        sd.BufferDesc.RefreshRate.Numerator = 60;  
        sd.BufferDesc.RefreshRate.Denominator = 1;  
        sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;  
        sd.OutputWindow = g_hWnd;  
        sd.SampleDesc.Count = 1;  
        sd.SampleDesc.Quality = 0;  
        sd.Windowed = FALSE;  
     
        for( UINT driverTypeIndex = 0; driverTypeIndex < numDriverTypes; driverTypeIndex++ )  
        {  
            g_driverType = driverTypes[driverTypeIndex];  
            hr = D3D10CreateDeviceAndSwapChain( NULL, g_driverType, NULL, createDeviceFlags,  
                D3D10_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice );  
            if( SUCCEEDED( hr ) )  
                break;  
        }  
        if( FAILED( hr ) )  
            return hr;  
     
        // Create a render target view  
        ID3D10Texture2D* pBackBuffer;  
        hr = g_pSwapChain->GetBuffer( 0, __uuidof( ID3D10Texture2D ), ( LPVOID* )&pBackBuffer );  
        if( FAILED( hr ) )  
            return hr;  
     
        hr = g_pd3dDevice->CreateRenderTargetView( pBackBuffer, NULL, &g_pRenderTargetView );  
        pBackBuffer->Release();  
        if( FAILED( hr ) )  
            return hr;  
     
        g_pd3dDevice->OMSetRenderTargets( 1, &g_pRenderTargetView, NULL );  
     
        // Setup the view port  
        D3D10_VIEWPORT vp;  
        vp.Width = width;  
        vp.Height = height;  
        vp.MinDepth = 0.0f;  
        vp.MaxDepth = 1.0f;  
        vp.TopLeftX = 0;  
        vp.TopLeftY = 0;  
        g_pd3dDevice->RSSetViewports( 1, &vp );  
     
        return S_OK;  


    My goal is to use the desktop in my intro. A single screen shot of the desktop would suffice, I would like to capture the desktop and use it in my intro for a few frames.

    My platform is Vista 32bit and my SDK is DX10.

    Thanks again
    Regards
    JonRambo
  • 10/12/2009 7:22 PM In reply to

    Re: Very advanced, screenshot at startup, DX10

    Answer
    Reply Quote
    in my belifes.. you should start every thing up as usural, the only thing you do not do is the winapi command "ShowWindow" or what its called..
    well you do it after you have take the screen shot! becus the device can be there with out the "flinkering" since it´s the window wich makes the flinkering!

    if you understand my point of the whole..
    Whow, thats a big memory leak...
    It sure is! and we are sinking!

    kartflygaren675@hotmail.com
  • 10/17/2009 12:44 PM In reply to

    Re: Very advanced, screenshot at startup, DX10

    Okay thank you for the input,

    Howcome its not obviouse to me how to take that screenshot?
Page 1 of 1 (3 items) Previous Next