代码如下:
LPDIRECTDRAW lpDDraw;
struct
{
int Width;
int Height;
int PixelPerLine; //
LPVOID ScreenColorBits_Ptr;//
RECT ScreenRect;//
} Context_Screen_Ptr;void CreateSurfaceFromContextScreen (LPDIRECTDRAWSURFACE * lplpDDSurface)
{
*lplpDDSurface= NULL; DDSURFACEDESC DDSurfaceDesc_temp;
DDRAW_INIT_STRUCT( DDSurfaceDesc_temp);
DDSurfaceDesc_temp.dwFlags|= DDSD_HEIGHT;
DDSurfaceDesc_temp.dwFlags|= DDSD_WIDTH;
DDSurfaceDesc_temp.dwFlags|= DDSD_PITCH;
DDSurfaceDesc_temp.dwFlags|= DDSD_LPSURFACE;
DDSurfaceDesc_temp.dwFlags|= DDSD_CAPS; DDSurfaceDesc_temp.dwHeight= Context_Screen_Ptr->Height;
DDSurfaceDesc_temp.dwWidth= Context_Screen_Ptr->Width;
DDSurfaceDesc_temp.lPitch= Context_Screen_Ptr->PixelPerLine;//一个字节代表8个bits
DDSurfaceDesc_temp.lpSurface= Context_Screen_Ptr->ScreenColorBits_Ptr;
DDSurfaceDesc_temp.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN| DDSCAPS_SYSTEMMEMORY; if (DD_OK==lpDDraw->CreateSurface ( &DDSurfaceDesc_temp, lplpDDSurface, NULL))
{ //这个CreateSurface出错//
return NULL;
}
//....
}
现在可以确定的是,执行到这儿时lpDDraw是对劲的,这个DDraw对象使用的是8bits色彩模式,用了自定义的调色板。全屏独占模式, DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX| DDSCL_EXCLUSIVE| DDSCL_ALLOWREBOOT
那个Context_Screen_Ptr结构的值为:
Context_Screen_Ptr->Widtd= 0x00000280
Context_Screen_Ptr->Height= 0x000001E0
Context_Screen_Ptr->PixelPerLine= 0x00000280
Context_Screen_Ptr->ScreenColorBits_Ptr= 0xA3E85A0 //也确定这儿就是有效的surface的缓存但执行完后,CreateSurface就返回了一个错误的参数, Error 80070057: One or more of the parameters passed to the method are incorrect。
因为我实在是drirectdraw苦手,一点也不通,搞的现在很狼狈又没有办法,只好来发帖询问了,希望路过的大侠能够指教一下。
LPDIRECTDRAW lpDDraw;
struct
{
int Width;
int Height;
int PixelPerLine; //
LPVOID ScreenColorBits_Ptr;//
RECT ScreenRect;//
} Context_Screen_Ptr;void CreateSurfaceFromContextScreen (LPDIRECTDRAWSURFACE * lplpDDSurface)
{
*lplpDDSurface= NULL; DDSURFACEDESC DDSurfaceDesc_temp;
DDRAW_INIT_STRUCT( DDSurfaceDesc_temp);
DDSurfaceDesc_temp.dwFlags|= DDSD_HEIGHT;
DDSurfaceDesc_temp.dwFlags|= DDSD_WIDTH;
DDSurfaceDesc_temp.dwFlags|= DDSD_PITCH;
DDSurfaceDesc_temp.dwFlags|= DDSD_LPSURFACE;
DDSurfaceDesc_temp.dwFlags|= DDSD_CAPS; DDSurfaceDesc_temp.dwHeight= Context_Screen_Ptr->Height;
DDSurfaceDesc_temp.dwWidth= Context_Screen_Ptr->Width;
DDSurfaceDesc_temp.lPitch= Context_Screen_Ptr->PixelPerLine;//一个字节代表8个bits
DDSurfaceDesc_temp.lpSurface= Context_Screen_Ptr->ScreenColorBits_Ptr;
DDSurfaceDesc_temp.ddsCaps.dwCaps= DDSCAPS_OFFSCREENPLAIN| DDSCAPS_SYSTEMMEMORY; if (DD_OK==lpDDraw->CreateSurface ( &DDSurfaceDesc_temp, lplpDDSurface, NULL))
{ //这个CreateSurface出错//
return NULL;
}
//....
}
现在可以确定的是,执行到这儿时lpDDraw是对劲的,这个DDraw对象使用的是8bits色彩模式,用了自定义的调色板。全屏独占模式, DDSCL_FULLSCREEN| DDSCL_ALLOWMODEX| DDSCL_EXCLUSIVE| DDSCL_ALLOWREBOOT
那个Context_Screen_Ptr结构的值为:
Context_Screen_Ptr->Widtd= 0x00000280
Context_Screen_Ptr->Height= 0x000001E0
Context_Screen_Ptr->PixelPerLine= 0x00000280
Context_Screen_Ptr->ScreenColorBits_Ptr= 0xA3E85A0 //也确定这儿就是有效的surface的缓存但执行完后,CreateSurface就返回了一个错误的参数, Error 80070057: One or more of the parameters passed to the method are incorrect。
因为我实在是drirectdraw苦手,一点也不通,搞的现在很狼狈又没有办法,只好来发帖询问了,希望路过的大侠能够指教一下。
你怎么算的?值是多少
这个缓存里保存的大小再三检查后,是0x00000280* 0x000001E0大小的缓冲区。