windows游戏编程大师技巧DEMO7_8的问题

zuoeraiwo 2012-11-22 07:39:14
以前运行都没问题的,今天运行的时候,发现程序运行一段时间后Blt函数调用返回DDERR_SURFACELOST,弄了半天都没弄出来,不知道是什么原因,现把Game_Main()部分的代码贴出如下,请各位帮忙看看:

int Game_Main(void *parms = NULL, int num_parms = 0)
{
// this is the main loop of the game, do all your processing
// here

DDBLTFX ddbltfx; // the blitter fx structure
static int feeling_counter = 0; // tracks how we feel :)
static int happy = 1; // let's start off being happy

// make sure this isn't executed again
if (window_closed)
return(0);

// for now test if user is hitting ESC and send WM_CLOSE
if (KEYDOWN(VK_ESCAPE))
{
PostMessage(main_window_handle,WM_CLOSE,0,0);
window_closed = 1;
} // end if

// use the blitter to erase the back buffer
// first initialize the DDBLTFX structure
DDRAW_INIT_STRUCT(ddbltfx);

// now set the color word info to the color we desire
ddbltfx.dwFillColor = 0;

// make the blitter call
if (FAILED(lpddsback->Blt(NULL, // pointer to dest RECT, NULL for whole thing
NULL, // pointer to source surface
NULL, // pointer to source RECT
DDBLT_COLORFILL | DDBLT_WAIT,
// do a color fill and wait if you have to
&ddbltfx))) // pointer to DDBLTFX holding info


return(0);

// initialize ddsd
DDRAW_INIT_STRUCT(ddsd);

// lock the back buffer surface
if (FAILED(lpddsback->Lock(NULL,&ddsd,
DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
NULL)))
return(0);


// increment how we feel
if (++feeling_counter > 200)
{
feeling_counter = 0;
happy = -happy;
} // end if

// draw all the happy faces
for (int face=0; face < 100; face++)
{
// are we happy or sad?
if (happy==1) // we are happy :)
Blit_Clipped(happy_faces[face].x,
happy_faces[face].y,
8,8,
happy_bitmap,
(UCHAR *)ddsd.lpSurface,
ddsd.lPitch);
else // we must be sad :(
Blit_Clipped(happy_faces[face].x,
happy_faces[face].y,
8,8,
sad_bitmap,
(UCHAR *)ddsd.lpSurface,
ddsd.lPitch);

} // end face

// move all happy faces
for (face=0; face < 100; face++)
{
// move
happy_faces[face].x+=happy_faces[face].xv;
happy_faces[face].y+=happy_faces[face].yv;

// check for off screen, if so wrap
if (happy_faces[face].x > SCREEN_WIDTH)
happy_faces[face].x = -8;
else
if (happy_faces[face].x < -8)
happy_faces[face].x = SCREEN_WIDTH;

if (happy_faces[face].y > SCREEN_HEIGHT)
happy_faces[face].y = -8;
else
if (happy_faces[face].y < -8)
happy_faces[face].y = SCREEN_HEIGHT;

} // end face

// unlock surface
if (FAILED(lpddsback->Unlock(NULL)))
return(0);

// flip the pages
while (FAILED(lpddsprimary->Flip(NULL, DDFLIP_WAIT)));

// wait a sec
Sleep(30);

// return success or failure or your own return code here
return(1);

} // end Game_Main
...全文
216 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
a86632678 2012-11-25
  • 打赏
  • 举报
回复
引用 3 楼 ADF1230 的回复:
引用 2 楼 a86632678 的回复: 引用 1 楼 zuoeraiwo 的回复:没人知道吗?自己顶下先! 请教下楼主一个问题 我刚刚开始学游戏编程,用的是VC2010。在基本的Direct3D 那里遇到了问题,利用LPDIRECT3DSURFACE9 载入磁盘位图时失败,提示 错误 1 error LNK2019: 无法解析的外部符号 _D3DXLoadSurface……
有加载啊,但是总提示错误。我找不出原因。。。。
神-气 2012-11-25
  • 打赏
  • 举报
回复
引用 2 楼 a86632678 的回复:
引用 1 楼 zuoeraiwo 的回复:没人知道吗?自己顶下先! 请教下楼主一个问题 我刚刚开始学游戏编程,用的是VC2010。在基本的Direct3D 那里遇到了问题,利用LPDIRECT3DSURFACE9 载入磁盘位图时失败,提示 错误 1 error LNK2019: 无法解析的外部符号 _D3DXLoadSurfaceFromFileA@……
需要加载D3dx9.lib
a86632678 2012-11-25
  • 打赏
  • 举报
回复
引用 1 楼 zuoeraiwo 的回复:
没人知道吗?自己顶下先!
请教下楼主一个问题 我刚刚开始学游戏编程,用的是VC2010。在基本的Direct3D 那里遇到了问题,利用LPDIRECT3DSURFACE9 载入磁盘位图时失败,提示 错误 1 error LNK2019: 无法解析的外部符号 _D3DXLoadSurfaceFromFileA@32,该符号在函数 "bool __cdecl Game_Init(struct HWND__ *)" (?Game_Init@@YA_NPAUHWND__@@@Z) 中被引用 E:\workspace\GameT1\Create_Surface\Create_Surface\winmain.obj Create_Surface 请问如何解决问题,谢谢了
zuoeraiwo 2012-11-22
  • 打赏
  • 举报
回复
没人知道吗?自己顶下先!

19,468

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 图形处理/算法
社区管理员
  • 图形处理/算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧