int Game_Main(void *parms = NULL, int num_parms = 0)
{
//按ESC键退出
if (KEYDOWN(VK_ESCAPE))
SendMessage(main_window_handle,WM_CLOSE,0,0);
memset(&ddsd,0,sizeof(ddsd));
ddsd.dwSize=sizeof(ddsd);
//锁定主显示表面
if (FAILED(lpddsprimary->Lock(NULL, &ddsd,
DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT,
NULL)))
return(0);
int lpitch32 = (int)(ddsd.lPitch >> 2);
UINT *video_buffer = (UINT *)ddsd.lpSurface;
for (int index=0; index < 1000; index++)
{
// select random position and color for 640x480x32
int red = rand()%256;
int green = rand()%256;
int blue = rand()%256;
int x = rand()%640;
int y = rand()%480;
UINT pixel = ((blue) + ((green) << 8) + ((red) << 16) + ((0) << 24));
//写色
video_buffer[x + y*lpitch32] = pixel;
} // end for index
//解锁主显示表面
if (FAILED(lpddsprimary->Unlock(NULL)))
return(0);
return(1);
} // end Game_Main