|
在WINCE下图片被撕裂的问题?请高手看一下代码。
[复制链接]
我在WINCE下用DDRAW做UI,发现图片有时被撕裂了。现在我想用三缓冲的方法去做,希望能解决这个问题。可是我怎么做好像都不成功。下面是代码。还请高手看一下。
LPDIRECTDRAW4 g_pDD = NULL;
LPDIRECTDRAWSURFACE4 g_pDDSPrimary = NULL;
LPDIRECTDRAWSURFACE4 g_pDDSBack = NULL;
LPDIRECTDRAWSURFACE4 g_pDDSBackTwo = NULL;
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | D DSCAPS_SYSTEMMEMORY ;
ddsd.dwBackBufferCount = 2;
if(FAILED(g_pDD->CreateSurface(&ddsd, &g_pDDSPrimary, NULL)))
{
ReleaseAllObjects();
RetalMsg(L"Unable to create surface failed");
return FALSE;
}
DDSCAPS2 ddscaps;
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
if(FAILED(g_pDDSPrimary->GetAttachedSurface(&ddscaps, &g_pDDSBack)))
{
ReleaseAllObjects();
RetalMsg(L"Unable to attach surface");
return FALSE;
}
ddscaps.dwCaps = DDSCAPS_BACKBUFFER ;
if(FAILED(g_pDDSPrimary->GetAttachedSurface(&ddscaps, &g_pDDSBackTwo)))
{
ReleaseAllObjects();
RetalMsg(L"Unable to attach surface");
return FALSE;
}
在显示总分要怎么做?这有二个后台缓冲,是不是我先向g_pDDSBack放入图片,g_pDDSPrimary->Flip(NULL, DDFLIP_WAIT); 再向g_pDDSBackTwo放,g_pDDSPrimary->Flip(NULL, DDFLIP_WAIT); 然后又回到g_pDDSBack,g_pDDSPrimary->Flip(NULL, DDFLIP_WAIT); 就这样不停的循环下去?
我用EnumAttachedSurfaces想把后台表面枚举出来,可是不知道回调函数中怎么写?
static HRESULT WINAPI
EnumSurfacesCallback(LPDIRECTDRAWSURFACE4 lpDDSurface,
LPDDSURFACEDESC2 lpDDSurfaceDesc,
LPVOID lpContext)
{
return 1;
|
|