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