Index: dxgltest/Tests2D.cpp |
— | — | @@ -577,6 +577,7 @@ |
578 | 578 | error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
579 | 579 | if(palette) palette->Release();
|
580 | 580 | DrawGradients(ddsd, (unsigned char *)ddsd.lpSurface, hWnd, palette, 1, 0);
|
| 581 | + DrawDitheredColor(&ddsd, (unsigned char *)ddsd.lpSurface, 0, FALSE);
|
581 | 582 | error = sprites[0].surface->Unlock(NULL);
|
582 | 583 | sprites[0].width = (float)ddsd.dwWidth;
|
583 | 584 | sprites[0].height = (float)ddsd.dwHeight;
|
— | — | @@ -697,6 +698,8 @@ |
698 | 699 | {
|
699 | 700 | if(stoptimer) return;
|
700 | 701 | DDSCAPS2 ddscaps;
|
| 702 | + DDBLTFX bltfx;
|
| 703 | + bltfx.dwSize = sizeof(DDBLTFX);
|
701 | 704 | ZeroMemory(&ddscaps,sizeof(DDSCAPS2));
|
702 | 705 | ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
703 | 706 | MultiDirectDrawSurface *temp1 = NULL;
|
— | — | @@ -707,7 +710,12 @@ |
708 | 711 | default:
|
709 | 712 | if(fullscreen) ddsurface->Flip(NULL,DDFLIP_WAIT);
|
710 | 713 | break;
|
711 | | - case 4: // FastBlt sprites
|
| 714 | + case 4: // BltFast sprites
|
| 715 | + if (backbuffers) ddsrender->GetAttachedSurface(&ddscaps, &temp1);
|
| 716 | + else temp1 = ddsrender;
|
| 717 | + bltfx.dwFillColor = 0;
|
| 718 | + temp1->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &bltfx);
|
| 719 | + if (backbuffers) temp1->Release();
|
712 | 720 | for(int i = 0; i < 16; i++)
|
713 | 721 | {
|
714 | 722 | sprites[i].x += sprites[i].xvelocity;
|
Index: dxgltest/surfacegen.cpp |
— | — | @@ -281,6 +281,83 @@ |
282 | 282 | }
|
283 | 283 | }
|
284 | 284 |
|
| 285 | +void DrawDitheredColor(DDSURFACEDESC2 *ddsd, unsigned char *buffer, DWORD color, BOOL invert)
|
| 286 | +{
|
| 287 | + DWORD *dwordptr = (DWORD*)buffer;
|
| 288 | + WORD *wordptr = (WORD*)buffer;
|
| 289 | + DWORD ptr;
|
| 290 | + BOOL pixel;
|
| 291 | + DWORD x, y;
|
| 292 | + switch (ddsd->ddpfPixelFormat.dwRGBBitCount)
|
| 293 | + {
|
| 294 | + default:
|
| 295 | + case 8:
|
| 296 | + for (y = 0; y < ddsd->dwHeight; y++)
|
| 297 | + {
|
| 298 | + ptr = ddsd->lPitch * y;
|
| 299 | + if (y & 1) pixel = TRUE;
|
| 300 | + else pixel = FALSE;
|
| 301 | + if (invert) pixel ^= 1;
|
| 302 | + for (x = 0; x < ddsd->dwWidth; x++)
|
| 303 | + {
|
| 304 | + if (pixel) buffer[ptr] = (unsigned char)color;
|
| 305 | + pixel ^= 1;
|
| 306 | + ptr++;
|
| 307 | + }
|
| 308 | + }
|
| 309 | + break;
|
| 310 | + case 15:
|
| 311 | + case 16:
|
| 312 | + for (y = 0; y < ddsd->dwHeight; y++)
|
| 313 | + {
|
| 314 | + ptr = (ddsd->lPitch / 2) * y;
|
| 315 | + if (y & 1) pixel = TRUE;
|
| 316 | + else pixel = FALSE;
|
| 317 | + if (invert) pixel ^= 1;
|
| 318 | + for (x = 0; x < ddsd->dwWidth; x++)
|
| 319 | + {
|
| 320 | + if (pixel) wordptr[ptr] = (WORD)color;
|
| 321 | + pixel ^= 1;
|
| 322 | + ptr++;
|
| 323 | + }
|
| 324 | + }
|
| 325 | + break;
|
| 326 | + case 24:
|
| 327 | + for (y = 0; y < ddsd->dwHeight; y++)
|
| 328 | + {
|
| 329 | + ptr = ddsd->lPitch * y;
|
| 330 | + if (y & 1) pixel = TRUE;
|
| 331 | + else pixel = FALSE;
|
| 332 | + if (invert) pixel ^= 1;
|
| 333 | + for (x = 0; x < ddsd->dwWidth; x++)
|
| 334 | + {
|
| 335 | + if (pixel) buffer[ptr] = (unsigned char)(color & 255);
|
| 336 | + ptr++;
|
| 337 | + if (pixel) buffer[ptr] = (unsigned char)((color >> 8) & 255);
|
| 338 | + ptr++;
|
| 339 | + if (pixel) buffer[ptr] = (unsigned char)((color >> 16) & 255);
|
| 340 | + pixel ^= 1;
|
| 341 | + ptr++;
|
| 342 | + }
|
| 343 | + }
|
| 344 | + break;
|
| 345 | + case 32:
|
| 346 | + for (y = 0; y < ddsd->dwHeight; y++)
|
| 347 | + {
|
| 348 | + ptr = (ddsd->lPitch / 4) * y;
|
| 349 | + if (y & 1) pixel = TRUE;
|
| 350 | + else pixel = FALSE;
|
| 351 | + if (invert) pixel ^= 1;
|
| 352 | + for (x = 0; x < ddsd->dwWidth; x++)
|
| 353 | + {
|
| 354 | + if (pixel) dwordptr[ptr] = (DWORD)color;
|
| 355 | + pixel ^= 1;
|
| 356 | + ptr++;
|
| 357 | + }
|
| 358 | + }
|
| 359 | + break;
|
| 360 | + }
|
| 361 | +}
|
285 | 362 |
|
286 | 363 | void DrawGradient(HDC hdc, int left, int right, int top, int bottom, DWORD color, bool usegdi)
|
287 | 364 | {
|
Index: dxgltest/surfacegen.h |
— | — | @@ -20,6 +20,7 @@ |
21 | 21 | #define _SURFACEGEN_H
|
22 | 22 |
|
23 | 23 | void DrawPalette(DDSURFACEDESC2 ddsd, unsigned char *buffer); // Palette test
|
| 24 | +void DrawDitheredColor(DDSURFACEDESC2 *ddsd, unsigned char *buffer, DWORD color, BOOL invert); // Draw a dithered color over the surface
|
24 | 25 | void DrawGradients(DDSURFACEDESC2 ddsd, unsigned char *buffer, HWND hwnd, LPDIRECTDRAWPALETTE palette, int type, DWORD color); // Gradients
|
25 | 26 | void DrawGDIPatterns(DDSURFACEDESC2 ddsd, HDC hDC, int type); // GDI pattern test
|
26 | 27 | void DrawROPPatterns(MultiDirectDrawSurface *primary, DDSPRITE *sprites, int backbuffers, int ddver, int bpp, DWORD *ropcaps,
|