I'm having an issue in porting my MFC/DirectX application to GapiDraw/MFC.
I'm porting an MFC extension DLL which has two primary types of clients - DC clients and DirectX clients. Internally the DLL caches bitmaps as DirectX offscreen surfaces which are BLTed to a back buffer surface which is also owned by the DLL. How do I create offscreen surfaces w/GapiDraw? My old code for doing this follows. When using GapiDraw it seems like I have to invoke OpenDisplay. I'm following the documentation and passing AfxGetMainWnd()->GetSafeHwnd(). Notice in the code below there is no need to reference a HWND.
// create the main DirectDraw object
TRYRET_DD (DirectDrawCreateEx( NULL, (LPVOID *)&lpDD1, IID_IDirectDraw7, NULL ), error);
// Set to normal mode
TRYRET_DD (lpDD1->SetCooperativeLevel( NULL, DDSCL_NORMAL ), error);
// Get DirectDraw7 interface
TRYRET_DD (lpDD1->QueryInterface(IID_IDirectDraw7, (LPVOID *)&m_lpDD), error);
lpDD1->Release();
DDSURFACEDESC2 ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof( ddsd );
ddsd.dwWidth = hSize;
ddsd.dwHeight = vSize;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
TRYRET_DD (m_lpDD->CreateSurface( &ddsd, &m_FrontBuffer , NULL ), error);
TRYRET_DD (m_lpDD->CreateSurface( &ddsd, &m_BackBuffer, NULL ), error);
Thanks,
Bill
I'm porting an MFC extension DLL which has two primary types of clients - DC clients and DirectX clients. Internally the DLL caches bitmaps as DirectX offscreen surfaces which are BLTed to a back buffer surface which is also owned by the DLL. How do I create offscreen surfaces w/GapiDraw? My old code for doing this follows. When using GapiDraw it seems like I have to invoke OpenDisplay. I'm following the documentation and passing AfxGetMainWnd()->GetSafeHwnd(). Notice in the code below there is no need to reference a HWND.
// create the main DirectDraw object
TRYRET_DD (DirectDrawCreateEx( NULL, (LPVOID *)&lpDD1, IID_IDirectDraw7, NULL ), error);
// Set to normal mode
TRYRET_DD (lpDD1->SetCooperativeLevel( NULL, DDSCL_NORMAL ), error);
// Get DirectDraw7 interface
TRYRET_DD (lpDD1->QueryInterface(IID_IDirectDraw7, (LPVOID *)&m_lpDD), error);
lpDD1->Release();
DDSURFACEDESC2 ddsd;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof( ddsd );
ddsd.dwWidth = hSize;
ddsd.dwHeight = vSize;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
TRYRET_DD (m_lpDD->CreateSurface( &ddsd, &m_FrontBuffer , NULL ), error);
TRYRET_DD (m_lpDD->CreateSurface( &ddsd, &m_BackBuffer, NULL ), error);
Thanks,
Bill