| Index: dxglcfg/surfacegen.cpp |
| — | — | @@ -1615,4 +1615,100 @@ |
| 1616 | 1616 | break;
|
| 1617 | 1617 | }
|
| 1618 | 1618 | }
|
| | 1619 | +}
|
| | 1620 | +
|
| | 1621 | +BOOL TextOutShadow(HDC hDC, int x, int y, LPCTSTR string, int count, COLORREF shadow)
|
| | 1622 | +{
|
| | 1623 | + int bkmode;
|
| | 1624 | + BOOL ret;
|
| | 1625 | + COLORREF color;
|
| | 1626 | + int x2, y2;
|
| | 1627 | + x2 = x + 1;
|
| | 1628 | + y2 = y + 1;
|
| | 1629 | + bkmode = GetBkMode(hDC);
|
| | 1630 | + if (bkmode == OPAQUE) TextOut(hDC, x, y, string, count); // Ensure background is painted
|
| | 1631 | + bkmode = SetBkMode(hDC, TRANSPARENT);
|
| | 1632 | + color = SetTextColor(hDC, shadow);
|
| | 1633 | + TextOut(hDC, x2, y2, string, count);
|
| | 1634 | + SetTextColor(hDC, color);
|
| | 1635 | + ret = TextOut(hDC, x, y, string, count);
|
| | 1636 | + SetBkMode(hDC, bkmode);
|
| | 1637 | + return ret;
|
| | 1638 | +}
|
| | 1639 | +
|
| | 1640 | +static const TCHAR strFormatTestTitle[] = _T("Surface format test");
|
| | 1641 | +static const TCHAR strFormatTestKeys1[] = _T("UP/DOWN: src type PGUP/DN: dest type ");
|
| | 1642 | +static const TCHAR strFormatTestKeys2[] = _T("LEFT/RIGHT: pattern TAB: render method");
|
| | 1643 | +static const TCHAR strFormatTestKeys3[] = _T("SPACE: show/hide help/info");
|
| | 1644 | +
|
| | 1645 | +void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud, int testpattern, int testmethod, int x, int y)
|
| | 1646 | +{
|
| | 1647 | + HDC hdc;
|
| | 1648 | + HRESULT error;
|
| | 1649 | + COLORREF oldcolor;
|
| | 1650 | + COLORREF oldbkcolor;
|
| | 1651 | + HFONT DefaultFont;
|
| | 1652 | + HFONT newfont;
|
| | 1653 | + RECT r;
|
| | 1654 | + int oldbk;
|
| | 1655 | + SIZE charsize;
|
| | 1656 | + int rows, cols;
|
| | 1657 | + int posx, posy;
|
| | 1658 | + if (!showhud) return;
|
| | 1659 | + error = surface->GetDC(&hdc);
|
| | 1660 | + if (FAILED(error)) return;
|
| | 1661 | + if (y < 350)
|
| | 1662 | + {
|
| | 1663 | + newfont = CreateFont(-8, -8, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
| | 1664 | + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
| | 1665 | + charsize.cx = 8;
|
| | 1666 | + charsize.cy = 8;
|
| | 1667 | + }
|
| | 1668 | + else if ((x > 1024) && (y > 600))
|
| | 1669 | + {
|
| | 1670 | + newfont = CreateFont(-16, -12, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
| | 1671 | + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
| | 1672 | + charsize.cx = 12;
|
| | 1673 | + charsize.cy = 16;
|
| | 1674 | + }
|
| | 1675 | + else
|
| | 1676 | + {
|
| | 1677 | + newfont = CreateFont(-12, -8, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
| | 1678 | + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
| | 1679 | + charsize.cx = 8;
|
| | 1680 | + charsize.cy = 12;
|
| | 1681 | + }
|
| | 1682 | + rows = y / charsize.cy;
|
| | 1683 | + cols = x / charsize.cx;
|
| | 1684 | + DefaultFont = (HFONT)SelectObject(hdc, newfont);
|
| | 1685 | + r.left = 0;
|
| | 1686 | + r.right = 128;
|
| | 1687 | + r.top = 0;
|
| | 1688 | + r.bottom = 16;
|
| | 1689 | + oldcolor = SetTextColor(hdc, RGB(255, 255, 255));
|
| | 1690 | + oldbkcolor = SetBkColor(hdc, RGB(0, 0, 255));
|
| | 1691 | + if(showhud == 2) oldbk = SetBkMode(hdc, TRANSPARENT);
|
| | 1692 | + else oldbk = SetBkMode(hdc, OPAQUE);
|
| | 1693 | + TextOutShadow(hdc, 0, 0, strFormatTestTitle, _tcslen(strFormatTestTitle), RGB(0, 0, 192));
|
| | 1694 | + TextOutShadow(hdc, 0, charsize.cy, strFormatTestKeys1, _tcslen(strFormatTestKeys1), RGB(0, 0, 192));
|
| | 1695 | + if (cols < (_tcslen(strFormatTestKeys1) + _tcslen(strFormatTestKeys2)))
|
| | 1696 | + {
|
| | 1697 | + posx = 0;
|
| | 1698 | + posy = 2 * charsize.cy;
|
| | 1699 | + }
|
| | 1700 | + else
|
| | 1701 | + {
|
| | 1702 | + posx = _tcslen(strFormatTestKeys1) * charsize.cx;
|
| | 1703 | + posy = charsize.cy;
|
| | 1704 | + }
|
| | 1705 | + TextOutShadow(hdc, posx, posy, strFormatTestKeys2, _tcslen(strFormatTestKeys2), RGB(0, 0, 192));
|
| | 1706 | + posx = 0;
|
| | 1707 | + posy += charsize.cy;
|
| | 1708 | + TextOutShadow(hdc, posx, posy, strFormatTestKeys3, _tcslen(strFormatTestKeys3), RGB(0, 0, 192));
|
| | 1709 | + SelectObject(hdc, DefaultFont);
|
| | 1710 | + DeleteObject(newfont);
|
| | 1711 | + SetTextColor(hdc, oldcolor);
|
| | 1712 | + SetBkColor(hdc, oldbkcolor);
|
| | 1713 | + SetBkMode(hdc, oldbk);
|
| | 1714 | + surface->ReleaseDC(hdc);
|
| 1619 | 1715 | } |
| \ No newline at end of file |
| Index: dxglcfg/surfacegen.h |
| — | — | @@ -28,5 +28,6 @@ |
| 29 | 29 | HWND hwnd, LPDIRECTDRAWPALETTE palette); // ROP pattern test
|
| 30 | 30 | void DrawRotatedBlt(MultiDirectDrawSurface *primary, DDSPRITE *sprites);
|
| 31 | 31 | void DrawColorKeyCompPatterns(DDSURFACEDESC2 ddsd, unsigned char *buffer, int bpp, int index);
|
| | 32 | +void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud, int testpattern, int testmethod, int x, int y);
|
| 32 | 33 |
|
| 33 | 34 | #endif //_SURFACEGEN_H |
| \ No newline at end of file |
| Index: dxglcfg/tests.cpp |
| — | — | @@ -49,7 +49,13 @@ |
| 50 | 50 | static int testtypes[] = {0,1,0,1,0,1,0,0,-1,1,0,0,0,0,0,0,0,0,2};
|
| 51 | 51 | static DWORD counter;
|
| 52 | 52 | static DWORD hotspotx,hotspoty;
|
| | 53 | +static int srcformat = 0;
|
| | 54 | +static int destformat = -1;
|
| | 55 | +static int showhud = 1;
|
| | 56 | +static int testpattern = 0;
|
| | 57 | +static int testmethod = 0;
|
| 53 | 58 |
|
| | 59 | +
|
| 54 | 60 | #define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
|
| 55 | 61 | struct COLORVERTEX
|
| 56 | 62 | {
|
| — | — | @@ -289,18 +295,22 @@ |
| 290 | 296 | {
|
| 291 | 297 | switch (wParam)
|
| 292 | 298 | {
|
| 293 | | - case VK_SPACE:
|
| | 299 | + case VK_SPACE: // Show/hide HUD
|
| 294 | 300 | break;
|
| 295 | | - case VK_UP:
|
| | 301 | + case VK_UP: // Source format -
|
| 296 | 302 | break;
|
| 297 | | - case VK_DOWN:
|
| | 303 | + case VK_DOWN: // Source format +
|
| 298 | 304 | break;
|
| 299 | | - case VK_LEFT:
|
| | 305 | + case VK_LEFT: // Test pattern -
|
| 300 | 306 | break;
|
| 301 | | - case VK_RIGHT:
|
| | 307 | + case VK_RIGHT: // Test pattern +
|
| 302 | 308 | break;
|
| 303 | | - case 'P':
|
| | 309 | + case VK_PRIOR: // Dest format - (PgUp)
|
| 304 | 310 | break;
|
| | 311 | + case VK_NEXT: // Dest format + (PgDn)
|
| | 312 | + break;
|
| | 313 | + case VK_TAB: // Render method
|
| | 314 | + break;
|
| 305 | 315 | }
|
| 306 | 316 | }
|
| 307 | 317 | }
|
| — | — | @@ -832,7 +842,8 @@ |
| 833 | 843 | HBITMAP bitmap;
|
| 834 | 844 | HGDIOBJ temp;
|
| 835 | 845 | HBRUSH brush;
|
| 836 | | - RECT r;
|
| | 846 | + RECT r, r1, r2;
|
| | 847 | + POINT p;
|
| 837 | 848 | DDCOLORKEY colorkey;
|
| 838 | 849 | DDBLTFX bltfx;
|
| 839 | 850 | void *bmppointer;
|
| — | — | @@ -1429,6 +1440,21 @@ |
| 1430 | 1441 | }
|
| 1431 | 1442 | }
|
| 1432 | 1443 | break;
|
| | 1444 | + case 18: // Surface format test
|
| | 1445 | + ddsrender->GetSurfaceDesc(&ddsd);
|
| | 1446 | + ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
|
| | 1447 | + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
| | 1448 | + ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL); // Initial source surface
|
| | 1449 | + srcformat = 0;
|
| | 1450 | + destformat = -1;
|
| | 1451 | + showhud = 1;
|
| | 1452 | + testpattern = 0;
|
| | 1453 | + testmethod = 0;
|
| | 1454 | + error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
|
| | 1455 | + DrawPalette(ddsd, (unsigned char*)ddsd.lpSurface);
|
| | 1456 | + error = sprites[0].surface->Unlock(NULL);
|
| | 1457 | + ddsrender->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
| | 1458 | + DrawFormatTestHUD(ddsrender, 0, -1, 1, 0, 0, ddsd.dwWidth, ddsd.dwHeight);
|
| 1433 | 1459 | default:
|
| 1434 | 1460 | break;
|
| 1435 | 1461 | }
|