|
|

楼主 |
发表于 2005-10-30 21:59:00
|
显示全部楼层
Re:极度困惑!如何在显存中创建16位色深表面?
我的代码如下,可显示16bit位图时竟然是黑屏?!!!
DDSURFACEDESC2 ddsd2; // working description
LPDIRECTDRAWSURFACE4 lpdds; // temporary surface
// set to access caps, width, and height
memset(&ddsd2,0,sizeof(ddsd));
ddsd2.dwSize = sizeof(ddsd2);
ddsd2.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
ddsd2.ddsCaps.dwCaps=DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY|DDSCAPS_LOCALVIDMEM;
ddsd2.dwWidth = width;
ddsd2.dwHeight= height;
ddsd2.ddpfPixelFormat.dwSize = sizeof(DDPIXELFORMAT);
ddsd2.ddpfPixelFormat.dwFlags= DDPF_RGB;
ddsd2.ddpfPixelFormat.dwRGBBitCount = (DWORD)2*8;
if (rgb16type()) //565
{
ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB;
ddsd2.ddpfPixelFormat.dwRGBBitCount = 16;
ddsd2.ddpfPixelFormat.dwRBitMask = 0x0000F800;
ddsd2.ddpfPixelFormat.dwGBitMask = 0x000007E0;
ddsd2.ddpfPixelFormat.dwBBitMask = 0x0000001F;
}
else
{
ddsd2.ddpfPixelFormat.dwFlags = DDPF_RGB;
ddsd2.ddpfPixelFormat.dwRGBBitCount = 16;
ddsd2.ddpfPixelFormat.dwRBitMask = 0x00007C00;
ddsd2.ddpfPixelFormat.dwGBitMask = 0x000003E0;
ddsd2.ddpfPixelFormat.dwBBitMask = 0x0000001F;
}
//////////////////////////
// create the surface
if (FAILED(lpdd->CreateSurface(&ddsd2,&lpdds,NULL)))
return(NULL); |
|