|
为什么通过以下的程序在我的电脑中创建DrectDraw Overlay表面就会出错呢?
还请各位高手赐教啊?
//DDrawInit()
void DDrawInit()
{
HRESULT ddrval;
DDPIXELFORMAT g_ddpfOverlayFormats[] = {
{sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0x7C00, 0x03e0, 0x001F, 0}, // 16-bit RGB 5:5:5
{sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x07e0, 0x001F, 0}, // 16-bit RGB 5:6:5
{sizeof(DDPIXELFORMAT), DDPF_FOURCC,MAKEFOURCC('U','Y','V','Y'),0,0,0,0,0}, // UYVY
{sizeof(DDPIXELFORMAT), DDPF_FOURCC,MAKEFOURCC('Y','U','Y','2'),0,0,0,0,0}, // YUY2
};
//
ddrval=DirectDrawCreateEx(NULL,(void**)&lpDD7,IID_IDirectDraw7,NULL);
if(ddrval != DD_OK) DDrawInitFailed(hWnd,ddrval,"DirectDrawCreateEx() call failed!");
//
// ddrval=lpDD7->SetCooperativeLevel(hWnd, DDSCL_NORMAL);
ddrval=lpDD7->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE ¦DDSCL_FULLSCREEN);
if(ddrval != DD_OK) DDrawInitFailed(hWnd,ddrval,"SetCooperativeLevel() call failed!");
//
ddrval=lpDD7->SetDisplayMode(1024,768,32,0, DDSDM_STANDARDVGAMODE);
if(ddrval !=DD_OK) DDrawInitFailed(hWnd,ddrval,"SetDisplayMode() call failed!");
// Create the primary surface
ZeroMemory(&ddsd, sizeof(ddsd)); // Fill structure with zeros
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
ddrval=lpDD7->CreateSurface(&ddsd, &lpDDSPrimary, NULL);
if (ddrval != DD_OK) DDrawInitFailed(hWnd, ddrval,"CreateSurface() Primary call failed");
//create overlay surface
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags= DDSD_CAPS ¦ DDSD_HEIGHT ¦ DDSD_WIDTH ¦ DDSD_PIXELFORMAT;
ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY ¦ DDSCAPS_VIDEOMEMORY;
ddsd.dwHeight = 576;
ddsd.dwWidth = 704;
memset(&ddsd.ddpfPixelFormat, 0, sizeof(DDPIXELFORMAT));
ddsd.ddpfPixelFormat = g_ddpfOverlayFormats[0];
//妈的RGB象素格式的就是不对,为什么?
ddrval = lpDD7->CreateSurface(&ddsd, &lpDDSOverlay, NULL);
if (ddrval != DD_OK) DDrawInitFailed(hWnd, ddrval,"Overlay surface creation failed");
}
//DDrawInitFailed()
HRESULT DDrawInitFailed(HWND hWnd,HRESULT hRet,LPCTSTR szError)
{
// char szBuffer[128];
// sprintf(szBuffer,szError);
DDrawFree();
MessageBox(hWnd,szError, "DirectDraw InWin Demo", MB_OK);
DestroyWindow(hWnd);
return hRet;
}
[em24] |
|