Original Post
I have some test code ripped from TOTWGPG. It''s just an test to get to know DirectDraw. But sometimes my code fails to blit. This is my code:
Anyone knows why it sometimes goed wrong?
Sand Hawk
----------------
-Earth is 98% full. Please delete anybody you can.
DDRAW_INIT_STRUCT(ddbltfx);
ddbltfx.dwFillColor = _RGB16BIT565(rand()%256, rand()%256, rand()%256);
int X1 = rand()%SCREENWIDTH ;
int Y1 = rand()%SCREENHEIGHT;
int X2 = rand()%SCREENWIDTH;
int Y2 = rand()%SCREENHEIGHT;
if (Y1 >= Y2)
{
int Temp = Y1;
Y1 = Y2 + 1;
Y2 = Temp;
}
if (X1 >= X2)
{
int Temp = X1;
X1 = X2 + 1;
X2 = Temp;
}
DestRect.left = X1;
DestRect.top = Y1;
DestRect.right = X2;
DestRect.bottom = Y2;
if (FAILED(lpddsPrimary->Blt(&DestRect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &ddbltfx)))
Log.Write("Failed to blit");