Index: ddraw/glTexture.cpp |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 16, 0xF800, 0x7E0, 0x1F, 0}, // 16 bit 565
|
76 | 76 | {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 24, 0xFF0000, 0xFF00, 0xFF, 0}, // 24 bit 888
|
77 | 77 | {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF0000, 0xFF00, 0xFF, 0}, // 32 bit 888
|
78 | | - {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF, 0xFF00, 0xFF0000, 0}, // 32 bit 888 BGR
|
| 78 | + {sizeof(DDPIXELFORMAT), DDPF_RGB, 0, 32, 0xFF, 0xFF00, 0xFF0000, 0}, // 32 bit 888 RGB
|
79 | 79 | {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xE0, 0x1C, 0x3, 0xFF00}, // 16-bit 8332
|
80 | 80 | {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0xF00, 0xF0, 0xF, 0xF000}, // 16-bit 4444
|
81 | 81 | {sizeof(DDPIXELFORMAT), DDPF_RGB|DDPF_ALPHAPIXELS, 0, 16, 0x7c00, 0x3E0, 0x1F, 0x8000}, // 16-bit 1555
|
Index: dxglcfg/surfacegen.cpp |
— | — | @@ -1636,51 +1636,105 @@ |
1637 | 1637 | return ret;
|
1638 | 1638 | }
|
1639 | 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");
|
| 1640 | +static const LPTSTR strFormatTestTitle = _T("Surface format test");
|
| 1641 | +static const LPTSTR strFormatTestKeys1 = _T("UP/DOWN: src type PGUP/DN: dest type ");
|
| 1642 | +static const LPTSTR strFormatTestKeys2 = _T("LEFT/RIGHT: pattern TAB: render method");
|
| 1643 | +static const LPTSTR strFormatTestKeys3 = _T("SPACE: show/hide help/info");
|
| 1644 | +static const LPTSTR strFormatTestStatus1 = _T("PATTERN: ");
|
| 1645 | +static const LPTSTR strFormatTestStatus2 = _T("METHOD: ");
|
| 1646 | +static const LPTSTR strFormatTestPatterns[] =
|
| 1647 | +{
|
| 1648 | + _T("Unknown "),
|
| 1649 | + _T("Palettes "),
|
| 1650 | + _T("Gradients "),
|
| 1651 | +};
|
| 1652 | +static const LPTSTR StrFormatTestMethods[] =
|
| 1653 | +{
|
| 1654 | + _T("Unknown"),
|
| 1655 | + _T("DDraw Blt"),
|
| 1656 | + _T("D3D Quad"),
|
| 1657 | + _T("Overlay")
|
| 1658 | +};
|
| 1659 | +static const int START_SURFACEFORMATS = __LINE__;
|
| 1660 | +static const LPTSTR strSurfaceFormats[] =
|
| 1661 | +{
|
| 1662 | + _T("Primary surface"), // -1
|
| 1663 | + _T("Same as primary"), // 0
|
| 1664 | + _T("8-bit Palette"),
|
| 1665 | + _T("8-bit 332"),
|
| 1666 | + _T("15-bit 555"),
|
| 1667 | + _T("16-bit 565"),
|
| 1668 | + _T("24-bit 888"),
|
| 1669 | + _T("32-bit 888"),
|
| 1670 | + _T("32-bit 888 RGB"),
|
| 1671 | + _T("16-bit 8332"),
|
| 1672 | + _T("16-bit 4444"),
|
| 1673 | + _T("16-bit 1555"),
|
| 1674 | + _T("32-bit 8888"),
|
| 1675 | + _T("8-bit luminance"),
|
| 1676 | + _T("8-bit alpha"),
|
| 1677 | + _T("8-bit lum/alpha"),
|
| 1678 | + _T("16-bit Zbuffer"),
|
| 1679 | + _T("24-bit Zbuffer"),
|
| 1680 | + _T("24-bit Z, 32bit"),
|
| 1681 | + _T("32-bit Zbuffer"),
|
| 1682 | + _T("32-bit Z/stencil"),
|
| 1683 | + _T("32-bit Z/st.rev")
|
| 1684 | +};
|
| 1685 | +static const int END_SURFACEFORMATS = __LINE__ - 4;
|
| 1686 | +static const int numsurfaceformats = END_SURFACEFORMATS - START_SURFACEFORMATS;
|
1644 | 1687 |
|
1645 | | -void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud, int testpattern, int testmethod, int x, int y)
|
| 1688 | +static const LPTSTR strErrorMessages[] =
|
1646 | 1689 | {
|
| 1690 | + _T("Unknown error"),
|
| 1691 | + _T("Error creating src surf: "),
|
| 1692 | + _T("Error locking src surf: "),
|
| 1693 | + _T("Error getting hdc: "),
|
| 1694 | + _T("Error creating dest surf: "),
|
| 1695 | + _T("Error blitting src to pri: "),
|
| 1696 | + _T("Error blitting src to dest: "),
|
| 1697 | + _T("Error blitting dest to pri: ")
|
| 1698 | +};
|
| 1699 | +
|
| 1700 | +void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud,
|
| 1701 | + int testpattern, int testmethod, int x, int y, int errorlocation, HRESULT error)
|
| 1702 | +{
|
1647 | 1703 | HDC hdc;
|
1648 | | - HRESULT error;
|
| 1704 | + HRESULT err;
|
1649 | 1705 | COLORREF oldcolor;
|
1650 | 1706 | COLORREF oldbkcolor;
|
1651 | 1707 | HFONT DefaultFont;
|
1652 | 1708 | HFONT newfont;
|
1653 | 1709 | RECT r;
|
| 1710 | + TCHAR buffer[256];
|
1654 | 1711 | int oldbk;
|
1655 | 1712 | SIZE charsize;
|
1656 | 1713 | int rows, cols;
|
| 1714 | + int formatrows;
|
1657 | 1715 | int posx, posy;
|
1658 | | - if (!showhud) return;
|
1659 | | - error = surface->GetDC(&hdc);
|
1660 | | - if (FAILED(error)) return;
|
| 1716 | + int formatposy;
|
| 1717 | + int formatfirst, formatlast;
|
| 1718 | + err = surface->GetDC(&hdc);
|
| 1719 | + if (FAILED(err)) return;
|
1661 | 1720 | if (y < 350)
|
1662 | 1721 | {
|
1663 | 1722 | newfont = CreateFont(-8, -8, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
1664 | 1723 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
1665 | | - charsize.cx = 8;
|
1666 | | - charsize.cy = 8;
|
1667 | 1724 | }
|
1668 | 1725 | else if ((x > 1024) && (y > 600))
|
1669 | 1726 | {
|
1670 | 1727 | newfont = CreateFont(-16, -12, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
1671 | 1728 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
1672 | | - charsize.cx = 12;
|
1673 | | - charsize.cy = 16;
|
1674 | 1729 | }
|
1675 | 1730 | else
|
1676 | 1731 | {
|
1677 | 1732 | newfont = CreateFont(-12, -8, 0, 0, 0, 0, 0, 0, OEM_CHARSET, OUT_DEVICE_PRECIS,
|
1678 | 1733 | CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, _T("Terminal"));
|
1679 | | - charsize.cx = 8;
|
1680 | | - charsize.cy = 12;
|
1681 | 1734 | }
|
| 1735 | + DefaultFont = (HFONT)SelectObject(hdc, newfont);
|
| 1736 | + GetTextExtentPoint(hdc, _T("A"), 1, &charsize);
|
1682 | 1737 | rows = y / charsize.cy;
|
1683 | 1738 | cols = x / charsize.cx;
|
1684 | | - DefaultFont = (HFONT)SelectObject(hdc, newfont);
|
1685 | 1739 | r.left = 0;
|
1686 | 1740 | r.right = 128;
|
1687 | 1741 | r.top = 0;
|
— | — | @@ -1687,24 +1741,59 @@ |
1688 | 1742 | r.bottom = 16;
|
1689 | 1743 | oldcolor = SetTextColor(hdc, RGB(255, 255, 255));
|
1690 | 1744 | oldbkcolor = SetBkColor(hdc, RGB(0, 0, 255));
|
1691 | | - if(showhud == 2) oldbk = SetBkMode(hdc, TRANSPARENT);
|
| 1745 | + if (showhud == 2) oldbk = SetBkMode(hdc, TRANSPARENT);
|
1692 | 1746 | 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)))
|
| 1747 | + if (showhud)
|
1696 | 1748 | {
|
| 1749 | + TextOutShadow(hdc, 0, 0, strFormatTestTitle, _tcslen(strFormatTestTitle), RGB(0, 0, 192));
|
| 1750 | + TextOutShadow(hdc, 0, charsize.cy, strFormatTestKeys1, _tcslen(strFormatTestKeys1), RGB(0, 0, 192));
|
| 1751 | + if (cols < (_tcslen(strFormatTestKeys1) + _tcslen(strFormatTestKeys2)))
|
| 1752 | + {
|
| 1753 | + posx = 0;
|
| 1754 | + posy = 2 * charsize.cy;
|
| 1755 | + }
|
| 1756 | + else
|
| 1757 | + {
|
| 1758 | + posx = _tcslen(strFormatTestKeys1) * charsize.cx;
|
| 1759 | + posy = charsize.cy;
|
| 1760 | + }
|
| 1761 | + TextOutShadow(hdc, posx, posy, strFormatTestKeys2, _tcslen(strFormatTestKeys2), RGB(0, 0, 192));
|
1697 | 1762 | posx = 0;
|
1698 | | - posy = 2 * charsize.cy;
|
| 1763 | + posy += charsize.cy;
|
| 1764 | + TextOutShadow(hdc, posx, posy, strFormatTestKeys3, _tcslen(strFormatTestKeys3), RGB(0, 0, 192));
|
| 1765 | + posy += charsize.cy;
|
| 1766 | + _tcscpy(buffer, strFormatTestStatus1);
|
| 1767 | + if (testpattern < 0) testpattern = 0;
|
| 1768 | + if (testpattern > 2) testpattern = 0;
|
| 1769 | + _tcscat(buffer, strFormatTestPatterns[testpattern]);
|
| 1770 | + _tcscat(buffer, strFormatTestStatus2);
|
| 1771 | + if (testmethod < 0) testmethod = 0;
|
| 1772 | + if (testmethod > 3) testmethod = 0;
|
| 1773 | + _tcscat(buffer, StrFormatTestMethods[testmethod]);
|
| 1774 | + TextOutShadow(hdc, posx, posy, buffer, _tcslen(buffer), RGB(0, 0, 192));
|
| 1775 | + // List source formats
|
| 1776 | + formatposy = posy + charsize.cy;
|
| 1777 | + SetBkMode(hdc, TRANSPARENT);
|
| 1778 | + formatrows = rows - (formatposy / charsize.cy) - 1;
|
| 1779 | + if (formatrows > numsurfaceformats)
|
| 1780 | + {
|
| 1781 | + formatfirst = -1;
|
| 1782 | + formatlast = numsurfaceformats - 2;
|
| 1783 | + }
|
| 1784 | + else
|
| 1785 | + {
|
| 1786 | +
|
| 1787 | + }
|
1699 | 1788 | }
|
1700 | | - else
|
| 1789 | + // Display error if present
|
| 1790 | + if (error)
|
1701 | 1791 | {
|
1702 | | - posx = _tcslen(strFormatTestKeys1) * charsize.cx;
|
1703 | | - posy = charsize.cy;
|
| 1792 | + SetBkMode(hdc, OPAQUE);
|
| 1793 | + SetBkColor(hdc, RGB(255, 0, 0));
|
| 1794 | + SetTextColor(hdc, RGB(255, 255, 255));
|
| 1795 | + if (errorlocation < 0) errorlocation = 0;
|
| 1796 | + if (errorlocation > 7) errorlocation = 0;
|
1704 | 1797 | }
|
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 | 1798 | SelectObject(hdc, DefaultFont);
|
1710 | 1799 | DeleteObject(newfont);
|
1711 | 1800 | SetTextColor(hdc, oldcolor);
|
Index: dxglcfg/surfacegen.h |
— | — | @@ -28,6 +28,7 @@ |
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 | +void DrawFormatTestHUD(MultiDirectDrawSurface *surface, int srcformat, int destformat, int showhud,
|
| 33 | + int testpattern, int testmethod, int x, int y, int errorlocation, HRESULT error);
|
33 | 34 |
|
34 | 35 | #endif //_SURFACEGEN_H |
\ No newline at end of file |
Index: dxglcfg/tests.cpp |
— | — | @@ -54,6 +54,7 @@ |
55 | 55 | static int showhud = 1;
|
56 | 56 | static int testpattern = 0;
|
57 | 57 | static int testmethod = 0;
|
| 58 | +static BOOL d3dfail = FALSE;
|
58 | 59 |
|
59 | 60 |
|
60 | 61 | #define FVF_COLORVERTEX (D3DFVF_VERTEX | D3DFVF_DIFFUSE | D3DFVF_SPECULAR)
|
— | — | @@ -423,6 +424,7 @@ |
424 | 425 | HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
|
425 | 426 | WNDCLASSEX wc;
|
426 | 427 | MSG Msg;
|
| 428 | + d3dfail = FALSE;
|
427 | 429 | ZeroMemory(&wc,sizeof(WNDCLASS));
|
428 | 430 | wc.cbSize = sizeof(WNDCLASSEX);
|
429 | 431 | wc.style = CS_HREDRAW | CS_VREDRAW;
|
— | — | @@ -475,6 +477,12 @@ |
476 | 478 | if(is3d) ddsd.ddsCaps.dwCaps |= DDSCAPS_3DDEVICE;
|
477 | 479 | }
|
478 | 480 | error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
| 481 | + if(FAILED(error))
|
| 482 | + {
|
| 483 | + d3dfail = TRUE;
|
| 484 | + ddsd.ddsCaps.dwCaps &= ~DDSCAPS_3DDEVICE;
|
| 485 | + error = ddinterface->CreateSurface(&ddsd,&ddsurface,NULL);
|
| 486 | + }
|
479 | 487 | if(!fullscreen)
|
480 | 488 | {
|
481 | 489 | error = ddinterface->CreateClipper(0,&ddclipper,NULL);
|
— | — | @@ -503,23 +511,45 @@ |
504 | 512 | ddsrender->SetPalette(pal);
|
505 | 513 | }
|
506 | 514 | else pal = NULL;
|
507 | | - if (is3d)
|
| 515 | + if (is3d )
|
508 | 516 | {
|
509 | 517 | error = ddinterface->QueryInterface(IID_IDirect3D7, (VOID**)&d3d7);
|
510 | | - error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
|
511 | | - error = ddsrender->GetSurfaceDesc(&ddsd);
|
512 | | - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
513 | | - ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
|
514 | | - memcpy(&ddsd.ddpfPixelFormat, &ddpfz, sizeof(DDPIXELFORMAT));
|
515 | | - error = ddinterface->CreateSurface(&ddsd, &zbuffer, NULL);
|
516 | | - error = ddsrender->AddAttachedSurface(zbuffer);
|
517 | | - error = d3d7->CreateDevice(IID_IDirect3DHALDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
518 | | - if (error != D3D_OK)
|
519 | | - error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
520 | | - ddsrender->GetSurfaceDesc(&ddsd);
|
521 | | - D3DVIEWPORT7 vp = { 0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f };
|
522 | | - error = d3d7dev->SetViewport(&vp);
|
523 | | - error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE);
|
| 518 | + if (FAILED(error)) d3dfail = TRUE;
|
| 519 | + else
|
| 520 | + {
|
| 521 | + error = d3d7->EnumZBufferFormats(IID_IDirect3DRGBDevice, zcallback, &ddpfz);
|
| 522 | + error = ddsrender->GetSurfaceDesc(&ddsd);
|
| 523 | + ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT | DDSD_PIXELFORMAT;
|
| 524 | + ddsd.ddsCaps.dwCaps = DDSCAPS_ZBUFFER | DDSCAPS_VIDEOMEMORY;
|
| 525 | + memcpy(&ddsd.ddpfPixelFormat, &ddpfz, sizeof(DDPIXELFORMAT));
|
| 526 | + error = ddinterface->CreateSurface(&ddsd, &zbuffer, NULL);
|
| 527 | + if (FAILED(error))
|
| 528 | + {
|
| 529 | + d3dfail = TRUE;
|
| 530 | + d3d7->Release();
|
| 531 | + }
|
| 532 | + else
|
| 533 | + {
|
| 534 | + error = ddsrender->AddAttachedSurface(zbuffer);
|
| 535 | + error = d3d7->CreateDevice(IID_IDirect3DHALDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
| 536 | + if (error != D3D_OK)
|
| 537 | + error = d3d7->CreateDevice(IID_IDirect3DRGBDevice, (LPDIRECTDRAWSURFACE7)ddsrender->GetSurface(), &d3d7dev);
|
| 538 | + if (error != D3D_OK)
|
| 539 | + {
|
| 540 | + d3dfail = TRUE;
|
| 541 | + zbuffer->Release();
|
| 542 | + d3d7->Release();
|
| 543 | + }
|
| 544 | + else
|
| 545 | + {
|
| 546 | + ddsrender->GetSurfaceDesc(&ddsd);
|
| 547 | + D3DVIEWPORT7 vp = { 0,0,ddsd.dwWidth,ddsd.dwHeight,0.0f,1.0f };
|
| 548 | + error = d3d7dev->SetViewport(&vp);
|
| 549 | + error = d3d7dev->SetRenderState(D3DRENDERSTATE_ZENABLE, TRUE);
|
| 550 | + d3dfail = FALSE;
|
| 551 | + }
|
| 552 | + }
|
| 553 | + }
|
524 | 554 | }
|
525 | 555 | InitTest(testnum);
|
526 | 556 | if(!fullscreen) SendMessage(hWnd,WM_PAINT,0,0);
|
— | — | @@ -1454,7 +1484,7 @@ |
1455 | 1485 | DrawPalette(ddsd, (unsigned char*)ddsd.lpSurface);
|
1456 | 1486 | error = sprites[0].surface->Unlock(NULL);
|
1457 | 1487 | ddsrender->Blt(NULL, sprites[0].surface, NULL, DDBLT_WAIT, NULL);
|
1458 | | - DrawFormatTestHUD(ddsrender, 0, -1, 1, 0, 0, ddsd.dwWidth, ddsd.dwHeight);
|
| 1488 | + DrawFormatTestHUD(ddsrender, 0, -1, 1, 0, 0, ddsd.dwWidth, ddsd.dwHeight, 0, DD_OK);
|
1459 | 1489 | default:
|
1460 | 1490 | break;
|
1461 | 1491 | }
|