返回

请教大家一下如何用directdraw可以直接创建一个rgb32的overlay surface, 我试了几次 没成功 网上都是用backbuffer然后用blit贴到主画面的办法 我不想用 我希望得到一块可以直接操作的显存来验证自己的2d engine. 我的代码大致是这样

intDDOverlayInit(){DDSURFACEDESC2 ddsd; // DirectDraw surface descriptorHRESULT hRet; // I'm not even going to try...DDPIXELFORMAT ddpfOverlayFormat =// The pixel format that we want the surface to be in{sizeof(DDPIXELFORMAT),DDPF_RGB,0, 16,0xF800, 0x07e0, 0x001F, // 16 bit RGB 5:6:50};

// Setup the overlay surface's attributes in the surface descriptormemset(&ddsd, 0, sizeof(ddsd));ddsd.dwSize = sizeof(ddsd);ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT;ddsd.ddsCaps.dwCaps = DDSCAPS_OVERLAY | DDSCAPS_VIDEOMEMORY;ddsd.dwWidth = BMAPX;ddsd.dwHeight = BMAPY;ddsd.ddpfPixelFormat = ddpfOverlayFormat; // Use 16 bit RGB 5:6:5 pixel format

// Attempt to create the surface with theses settingshRet = g_pDD->CreateSurface(&ddsd, &g_pDDSOverlay, NULL);if (hRet != DD_OK)return FALSE;return TRUE;}

最后总是得到 DDERR_INVALIDPIXELFORMAT, 不知道microsoft的overlay surface是不是真的支持rgb 还是只支持fourcc阿...

名字: 自动排版 密码:

回复 | (666) | sandman | 2005-04-18 12:04:58