Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1626,180 +1626,83 @@ |
1627 | 1627 | currmode.dmSize = sizeof(DEVMODE);
|
1628 | 1628 | EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&currmode);
|
1629 | 1629 | this->currmode.dmSize = 0;
|
1630 | | - switch(dxglcfg.scaler)
|
| 1630 | + switch (dxglcfg.fullmode)
|
1631 | 1631 | {
|
1632 | | - case 0: // No scaling, switch mode
|
1633 | | - default:
|
1634 | | - newmode.dmSize = sizeof(DEVMODE);
|
1635 | | - newmode.dmDriverExtra = 0;
|
1636 | | - newmode.dmPelsWidth = dwWidth;
|
1637 | | - newmode.dmPelsHeight = dwHeight;
|
1638 | | - if(dxglcfg.colormode)
|
1639 | | - newmode.dmBitsPerPel = dwBPP;
|
1640 | | - else newmode.dmBitsPerPel = currmode.dmBitsPerPel;
|
1641 | | - newmode.dmDisplayFrequency = dwRefreshRate;
|
1642 | | - if(dwRefreshRate) newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
1643 | | - else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
1644 | | - flags = 0;
|
1645 | | - if(fullscreen) flags |= CDS_FULLSCREEN;
|
1646 | | - error = ChangeDisplaySettingsEx(NULL,&newmode,NULL,flags,NULL);
|
1647 | | - switch(error)
|
| 1632 | + case 0:
|
| 1633 | + case 1:
|
| 1634 | + default: // Fullscreen modes and fallback
|
| 1635 | + switch (dxglcfg.scaler)
|
1648 | 1636 | {
|
1649 | | - case DISP_CHANGE_SUCCESSFUL:
|
1650 | | - if (fullscreen) this->currmode = newmode;
|
1651 | | - internalx = primaryx = screenx = newmode.dmPelsWidth;
|
1652 | | - internaly = primaryy = screeny = newmode.dmPelsHeight;
|
1653 | | - internalbpp = screenbpp = newmode.dmBitsPerPel;
|
1654 | | - primarybpp = dwBPP;
|
1655 | | - if(dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1656 | | - else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1657 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
1658 | | - glRenderer_SetBPP(this->renderer, primarybpp);
|
1659 | | - primarylost = true;
|
1660 | | - TRACE_EXIT(23,DD_OK);
|
1661 | | - return DD_OK;
|
1662 | | - case DISP_CHANGE_BADMODE:
|
1663 | | - TRACE_RET(HRESULT,23,DDERR_INVALIDMODE);
|
1664 | | - case DISP_CHANGE_BADFLAGS:
|
1665 | | - TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1666 | | - case DISP_CHANGE_BADDUALVIEW:
|
1667 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1668 | | - case DISP_CHANGE_BADPARAM:
|
1669 | | - TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1670 | | - case DISP_CHANGE_FAILED:
|
1671 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1672 | | - case DISP_CHANGE_NOTUPDATED:
|
1673 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1674 | | - case DISP_CHANGE_RESTART:
|
1675 | | - TRACE_RET(HRESULT,23,DDERR_UNSUPPORTEDMODE);
|
| 1637 | + case 0: // No scaling, switch mode
|
1676 | 1638 | default:
|
1677 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1678 | | - }
|
1679 | | - TRACE_RET(HRESULT,23,DDERR_GENERIC);
|
1680 | | - break;
|
1681 | | - case 1: // Stretch to screen
|
1682 | | - primaryx = dwWidth;
|
1683 | | - internalx = screenx = currmode.dmPelsWidth;
|
1684 | | - primaryy = dwHeight;
|
1685 | | - internaly = screeny = currmode.dmPelsHeight;
|
1686 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1687 | | - else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1688 | | - if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1689 | | - else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1690 | | - primarybpp = dwBPP;
|
1691 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
1692 | | - glRenderer_SetBPP(this->renderer, primarybpp);
|
1693 | | - primarylost = true;
|
1694 | | - TRACE_EXIT(23,DD_OK);
|
1695 | | - return DD_OK;
|
1696 | | - break;
|
1697 | | - case 2: // Scale to screen, aspect corrected
|
1698 | | - primaryx = dwWidth;
|
1699 | | - screenx = currmode.dmPelsWidth;
|
1700 | | - primaryy = dwHeight;
|
1701 | | - screeny = currmode.dmPelsHeight;
|
1702 | | - if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
|
1703 | | - {
|
1704 | | - aspect = (float)dwWidth / (float)dwHeight;
|
1705 | | - xmul = (float)screenx / (float)dwWidth;
|
1706 | | - ymul = (float)screeny / (float)dwHeight;
|
1707 | | - if ((float)dwWidth*(float)ymul > (float)screenx)
|
| 1639 | + newmode.dmSize = sizeof(DEVMODE);
|
| 1640 | + newmode.dmDriverExtra = 0;
|
| 1641 | + newmode.dmPelsWidth = dwWidth;
|
| 1642 | + newmode.dmPelsHeight = dwHeight;
|
| 1643 | + if (dxglcfg.colormode)
|
| 1644 | + newmode.dmBitsPerPel = dwBPP;
|
| 1645 | + else newmode.dmBitsPerPel = currmode.dmBitsPerPel;
|
| 1646 | + newmode.dmDisplayFrequency = dwRefreshRate;
|
| 1647 | + if (dwRefreshRate) newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
| 1648 | + else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
| 1649 | + flags = 0;
|
| 1650 | + if (fullscreen) flags |= CDS_FULLSCREEN;
|
| 1651 | + error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
| 1652 | + switch (error)
|
1708 | 1653 | {
|
1709 | | - internalx = (DWORD)((float)dwWidth * (float)xmul);
|
1710 | | - internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 1654 | + case DISP_CHANGE_SUCCESSFUL:
|
| 1655 | + if (fullscreen) this->currmode = newmode;
|
| 1656 | + internalx = primaryx = screenx = newmode.dmPelsWidth;
|
| 1657 | + internaly = primaryy = screeny = newmode.dmPelsHeight;
|
| 1658 | + internalbpp = screenbpp = newmode.dmBitsPerPel;
|
| 1659 | + primarybpp = dwBPP;
|
| 1660 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1661 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
| 1662 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1663 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1664 | + primarylost = true;
|
| 1665 | + TRACE_EXIT(23, DD_OK);
|
| 1666 | + return DD_OK;
|
| 1667 | + case DISP_CHANGE_BADMODE:
|
| 1668 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDMODE);
|
| 1669 | + case DISP_CHANGE_BADFLAGS:
|
| 1670 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1671 | + case DISP_CHANGE_BADDUALVIEW:
|
| 1672 | + TRACE_RET(HRESULT, 23, DDERR_GENERIC);
|
| 1673 | + case DISP_CHANGE_BADPARAM:
|
| 1674 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 1675 | + case DISP_CHANGE_FAILED:
|
| 1676 | + TRACE_RET(HRESULT, 23, DDERR_GENERIC);
|
| 1677 | + case DISP_CHANGE_NOTUPDATED:
|
| 1678 | + TRACE_RET(HRESULT, 23, DDERR_GENERIC);
|
| 1679 | + case DISP_CHANGE_RESTART:
|
| 1680 | + TRACE_RET(HRESULT, 23, DDERR_UNSUPPORTEDMODE);
|
| 1681 | + default:
|
| 1682 | + TRACE_RET(HRESULT, 23, DDERR_GENERIC);
|
1711 | 1683 | }
|
1712 | | - else
|
1713 | | - {
|
1714 | | - internalx = (DWORD)((float)dwWidth * (float)ymul);
|
1715 | | - internaly = (DWORD)((float)dwHeight * (float)ymul);
|
1716 | | - }
|
1717 | | - }
|
1718 | | - else
|
1719 | | - {
|
1720 | | - aspect = dxglcfg.aspect;
|
1721 | | - if (screenx/aspect > screeny)
|
1722 | | - {
|
1723 | | - internalx = (DWORD)((float)screeny * (float)aspect);
|
1724 | | - internaly = screeny;
|
1725 | | - }
|
1726 | | - else
|
1727 | | - {
|
1728 | | - internalx = screenx;
|
1729 | | - internaly = (DWORD)((float)screenx / (float)aspect);
|
1730 | | - }
|
1731 | | - }
|
1732 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1733 | | - else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1734 | | - if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1735 | | - else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1736 | | - primarybpp = dwBPP;
|
1737 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
1738 | | - glRenderer_SetBPP(this->renderer, primarybpp);
|
1739 | | - primarylost = true;
|
1740 | | - TRACE_EXIT(23,DD_OK);
|
1741 | | - return DD_OK;
|
1742 | | - break;
|
1743 | | - case 3: // Center image
|
1744 | | - primaryx = internalx = dwWidth;
|
1745 | | - screenx = currmode.dmPelsWidth;
|
1746 | | - primaryy = internaly = dwHeight;
|
1747 | | - screeny = currmode.dmPelsHeight;
|
1748 | | - primarybpp = dwBPP;
|
1749 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1750 | | - else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1751 | | - if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1752 | | - else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1753 | | - InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
1754 | | - glRenderer_SetBPP(this->renderer, primarybpp);
|
1755 | | - TRACE_EXIT(23,DD_OK);
|
1756 | | - return DD_OK;
|
1757 | | - break;
|
1758 | | - case 4: // Switch then stretch
|
1759 | | - case 5: // Switch then scale
|
1760 | | - case 6: // Switch then center
|
1761 | | - newmode.dmSize = sizeof(DEVMODE);
|
1762 | | - newmode.dmDriverExtra = 0;
|
1763 | | - newmode.dmPelsWidth = dwWidth;
|
1764 | | - newmode.dmPelsHeight = dwHeight;
|
1765 | | - if(dxglcfg.colormode)
|
1766 | | - newmode.dmBitsPerPel = dwBPP;
|
1767 | | - else newmode.dmBitsPerPel = currmode.dmBitsPerPel;
|
1768 | | - newmode.dmDisplayFrequency = dwRefreshRate;
|
1769 | | - if(dwRefreshRate) newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
1770 | | - else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
1771 | | - flags = 0;
|
1772 | | - if(fullscreen) flags |= CDS_FULLSCREEN;
|
1773 | | - error = ChangeDisplaySettingsEx(NULL,&newmode,NULL,flags,NULL);
|
1774 | | - if(error != DISP_CHANGE_SUCCESSFUL)
|
1775 | | - {
|
1776 | | - newmode2 = FindClosestMode(newmode);
|
1777 | | - error = ChangeDisplaySettingsEx(NULL,&newmode2,NULL,flags,NULL);
|
1778 | | - }
|
1779 | | - else newmode2 = newmode;
|
1780 | | - if (error == DISP_CHANGE_SUCCESSFUL) this->currmode = newmode2;
|
1781 | | - switch(dxglcfg.scaler)
|
1782 | | - {
|
1783 | | - case 4:
|
| 1684 | + TRACE_RET(HRESULT, 23, DDERR_GENERIC);
|
| 1685 | + break;
|
| 1686 | + case 1: // Stretch to screen
|
1784 | 1687 | primaryx = dwWidth;
|
1785 | | - internalx = screenx = newmode2.dmPelsWidth;
|
| 1688 | + internalx = screenx = currmode.dmPelsWidth;
|
1786 | 1689 | primaryy = dwHeight;
|
1787 | | - internaly = screeny = newmode2.dmPelsHeight;
|
1788 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1789 | | - else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1690 | + internaly = screeny = currmode.dmPelsHeight;
|
| 1691 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1692 | + else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1790 | 1693 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1791 | | - else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
| 1694 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1792 | 1695 | primarybpp = dwBPP;
|
1793 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
| 1696 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
1794 | 1697 | glRenderer_SetBPP(this->renderer, primarybpp);
|
1795 | 1698 | primarylost = true;
|
1796 | | - TRACE_EXIT(23,DD_OK);
|
| 1699 | + TRACE_EXIT(23, DD_OK);
|
1797 | 1700 | return DD_OK;
|
1798 | 1701 | break;
|
1799 | | - case 5:
|
| 1702 | + case 2: // Scale to screen, aspect corrected
|
1800 | 1703 | primaryx = dwWidth;
|
1801 | | - screenx = newmode2.dmPelsWidth;
|
| 1704 | + screenx = currmode.dmPelsWidth;
|
1802 | 1705 | primaryy = dwHeight;
|
1803 | | - screeny = newmode2.dmPelsHeight;
|
| 1706 | + screeny = currmode.dmPelsHeight;
|
1804 | 1707 | if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
|
1805 | 1708 | {
|
1806 | 1709 | aspect = (float)dwWidth / (float)dwHeight;
|
— | — | @@ -1831,81 +1734,199 @@ |
1832 | 1735 | }
|
1833 | 1736 | }
|
1834 | 1737 | if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1835 | | - else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1738 | + else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1836 | 1739 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1837 | | - else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
| 1740 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1838 | 1741 | primarybpp = dwBPP;
|
1839 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
| 1742 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
1840 | 1743 | glRenderer_SetBPP(this->renderer, primarybpp);
|
1841 | 1744 | primarylost = true;
|
1842 | | - TRACE_EXIT(23,DD_OK);
|
| 1745 | + TRACE_EXIT(23, DD_OK);
|
1843 | 1746 | return DD_OK;
|
1844 | 1747 | break;
|
1845 | | - case 6:
|
1846 | | - default:
|
| 1748 | + case 3: // Center image
|
1847 | 1749 | primaryx = internalx = dwWidth;
|
1848 | | - screenx = newmode2.dmPelsWidth;
|
| 1750 | + screenx = currmode.dmPelsWidth;
|
1849 | 1751 | primaryy = internaly = dwHeight;
|
1850 | | - screeny = newmode2.dmPelsHeight;
|
| 1752 | + screeny = currmode.dmPelsHeight;
|
1851 | 1753 | primarybpp = dwBPP;
|
1852 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1853 | | - else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1754 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1755 | + else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1854 | 1756 | if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1855 | | - else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
1856 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
| 1757 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
| 1758 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
1857 | 1759 | glRenderer_SetBPP(this->renderer, primarybpp);
|
1858 | | - primarylost = true;
|
1859 | | - TRACE_EXIT(23,DD_OK);
|
| 1760 | + TRACE_EXIT(23, DD_OK);
|
1860 | 1761 | return DD_OK;
|
1861 | 1762 | break;
|
1862 | | - }
|
1863 | | - break;
|
1864 | | - case 7: // Crop to screen, aspect corrected
|
1865 | | - primaryx = dwWidth;
|
1866 | | - screenx = currmode.dmPelsWidth;
|
1867 | | - primaryy = dwHeight;
|
1868 | | - screeny = currmode.dmPelsHeight;
|
1869 | | - if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
|
1870 | | - {
|
1871 | | - aspect = (float)dwWidth / (float)dwHeight;
|
1872 | | - xmul = (float)screenx / (float)dwWidth;
|
1873 | | - ymul = (float)screeny / (float)dwHeight;
|
1874 | | - if ((float)dwWidth*(float)ymul < (float)screenx)
|
| 1763 | + case 4: // Switch then stretch
|
| 1764 | + case 5: // Switch then scale
|
| 1765 | + case 6: // Switch then center
|
| 1766 | + newmode.dmSize = sizeof(DEVMODE);
|
| 1767 | + newmode.dmDriverExtra = 0;
|
| 1768 | + newmode.dmPelsWidth = dwWidth;
|
| 1769 | + newmode.dmPelsHeight = dwHeight;
|
| 1770 | + if (dxglcfg.colormode)
|
| 1771 | + newmode.dmBitsPerPel = dwBPP;
|
| 1772 | + else newmode.dmBitsPerPel = currmode.dmBitsPerPel;
|
| 1773 | + newmode.dmDisplayFrequency = dwRefreshRate;
|
| 1774 | + if (dwRefreshRate) newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY;
|
| 1775 | + else newmode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
|
| 1776 | + flags = 0;
|
| 1777 | + if (fullscreen) flags |= CDS_FULLSCREEN;
|
| 1778 | + error = ChangeDisplaySettingsEx(NULL, &newmode, NULL, flags, NULL);
|
| 1779 | + if (error != DISP_CHANGE_SUCCESSFUL)
|
1875 | 1780 | {
|
1876 | | - internalx = (DWORD)((float)dwWidth * (float)xmul);
|
1877 | | - internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 1781 | + newmode2 = FindClosestMode(newmode);
|
| 1782 | + error = ChangeDisplaySettingsEx(NULL, &newmode2, NULL, flags, NULL);
|
1878 | 1783 | }
|
1879 | | - else
|
| 1784 | + else newmode2 = newmode;
|
| 1785 | + if (error == DISP_CHANGE_SUCCESSFUL) this->currmode = newmode2;
|
| 1786 | + switch (dxglcfg.scaler)
|
1880 | 1787 | {
|
1881 | | - internalx = (DWORD)((float)dwWidth * (float)ymul);
|
1882 | | - internaly = (DWORD)((float)dwHeight * (float)ymul);
|
| 1788 | + case 4:
|
| 1789 | + primaryx = dwWidth;
|
| 1790 | + internalx = screenx = newmode2.dmPelsWidth;
|
| 1791 | + primaryy = dwHeight;
|
| 1792 | + internaly = screeny = newmode2.dmPelsHeight;
|
| 1793 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1794 | + else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1795 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1796 | + else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
| 1797 | + primarybpp = dwBPP;
|
| 1798 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1799 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1800 | + primarylost = true;
|
| 1801 | + TRACE_EXIT(23, DD_OK);
|
| 1802 | + return DD_OK;
|
| 1803 | + break;
|
| 1804 | + case 5:
|
| 1805 | + primaryx = dwWidth;
|
| 1806 | + screenx = newmode2.dmPelsWidth;
|
| 1807 | + primaryy = dwHeight;
|
| 1808 | + screeny = newmode2.dmPelsHeight;
|
| 1809 | + if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
|
| 1810 | + {
|
| 1811 | + aspect = (float)dwWidth / (float)dwHeight;
|
| 1812 | + xmul = (float)screenx / (float)dwWidth;
|
| 1813 | + ymul = (float)screeny / (float)dwHeight;
|
| 1814 | + if ((float)dwWidth*(float)ymul > (float)screenx)
|
| 1815 | + {
|
| 1816 | + internalx = (DWORD)((float)dwWidth * (float)xmul);
|
| 1817 | + internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 1818 | + }
|
| 1819 | + else
|
| 1820 | + {
|
| 1821 | + internalx = (DWORD)((float)dwWidth * (float)ymul);
|
| 1822 | + internaly = (DWORD)((float)dwHeight * (float)ymul);
|
| 1823 | + }
|
| 1824 | + }
|
| 1825 | + else
|
| 1826 | + {
|
| 1827 | + aspect = dxglcfg.aspect;
|
| 1828 | + if (screenx / aspect > screeny)
|
| 1829 | + {
|
| 1830 | + internalx = (DWORD)((float)screeny * (float)aspect);
|
| 1831 | + internaly = screeny;
|
| 1832 | + }
|
| 1833 | + else
|
| 1834 | + {
|
| 1835 | + internalx = screenx;
|
| 1836 | + internaly = (DWORD)((float)screenx / (float)aspect);
|
| 1837 | + }
|
| 1838 | + }
|
| 1839 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1840 | + else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1841 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1842 | + else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
| 1843 | + primarybpp = dwBPP;
|
| 1844 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1845 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1846 | + primarylost = true;
|
| 1847 | + TRACE_EXIT(23, DD_OK);
|
| 1848 | + return DD_OK;
|
| 1849 | + break;
|
| 1850 | + case 6:
|
| 1851 | + default:
|
| 1852 | + primaryx = internalx = dwWidth;
|
| 1853 | + screenx = newmode2.dmPelsWidth;
|
| 1854 | + primaryy = internaly = dwHeight;
|
| 1855 | + screeny = newmode2.dmPelsHeight;
|
| 1856 | + primarybpp = dwBPP;
|
| 1857 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1858 | + else internalbpp = screenbpp = newmode2.dmBitsPerPel;
|
| 1859 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1860 | + else internalrefresh = primaryrefresh = screenrefresh = newmode2.dmDisplayFrequency;
|
| 1861 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1862 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1863 | + primarylost = true;
|
| 1864 | + TRACE_EXIT(23, DD_OK);
|
| 1865 | + return DD_OK;
|
| 1866 | + break;
|
1883 | 1867 | }
|
1884 | | - }
|
1885 | | - else
|
1886 | | - {
|
1887 | | - aspect = dxglcfg.aspect;
|
1888 | | - if (screenx/aspect < screeny)
|
| 1868 | + break;
|
| 1869 | + case 7: // Crop to screen, aspect corrected
|
| 1870 | + primaryx = dwWidth;
|
| 1871 | + screenx = currmode.dmPelsWidth;
|
| 1872 | + primaryy = dwHeight;
|
| 1873 | + screeny = currmode.dmPelsHeight;
|
| 1874 | + if (_isnan(dxglcfg.aspect) || dxglcfg.aspect <= 0)
|
1889 | 1875 | {
|
1890 | | - internalx = (DWORD)((float)screeny * (float)aspect);
|
1891 | | - internaly = screeny;
|
| 1876 | + aspect = (float)dwWidth / (float)dwHeight;
|
| 1877 | + xmul = (float)screenx / (float)dwWidth;
|
| 1878 | + ymul = (float)screeny / (float)dwHeight;
|
| 1879 | + if ((float)dwWidth*(float)ymul < (float)screenx)
|
| 1880 | + {
|
| 1881 | + internalx = (DWORD)((float)dwWidth * (float)xmul);
|
| 1882 | + internaly = (DWORD)((float)dwHeight * (float)xmul);
|
| 1883 | + }
|
| 1884 | + else
|
| 1885 | + {
|
| 1886 | + internalx = (DWORD)((float)dwWidth * (float)ymul);
|
| 1887 | + internaly = (DWORD)((float)dwHeight * (float)ymul);
|
| 1888 | + }
|
1892 | 1889 | }
|
1893 | 1890 | else
|
1894 | 1891 | {
|
1895 | | - internalx = screenx;
|
1896 | | - internaly = (DWORD)((float)screenx / (float)aspect);
|
| 1892 | + aspect = dxglcfg.aspect;
|
| 1893 | + if (screenx / aspect < screeny)
|
| 1894 | + {
|
| 1895 | + internalx = (DWORD)((float)screeny * (float)aspect);
|
| 1896 | + internaly = screeny;
|
| 1897 | + }
|
| 1898 | + else
|
| 1899 | + {
|
| 1900 | + internalx = screenx;
|
| 1901 | + internaly = (DWORD)((float)screenx / (float)aspect);
|
| 1902 | + }
|
1897 | 1903 | }
|
| 1904 | + if (dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
| 1905 | + else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
| 1906 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1907 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
| 1908 | + primarybpp = dwBPP;
|
| 1909 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1910 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1911 | + primarylost = true;
|
| 1912 | + TRACE_EXIT(23, DD_OK);
|
| 1913 | + return DD_OK;
|
| 1914 | + break;
|
1898 | 1915 | }
|
1899 | | - if(dxglcfg.colormode) internalbpp = screenbpp = dwBPP;
|
1900 | | - else internalbpp = screenbpp = currmode.dmBitsPerPel;
|
1901 | | - if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
1902 | | - else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
1903 | | - primarybpp = dwBPP;
|
1904 | | - InitGL(screenx,screeny,screenbpp,true,internalrefresh,hWnd,this,devwnd);
|
1905 | | - glRenderer_SetBPP(this->renderer, primarybpp);
|
1906 | | - primarylost = true;
|
1907 | | - TRACE_EXIT(23,DD_OK);
|
1908 | | - return DD_OK;
|
1909 | 1916 | break;
|
| 1917 | + case 2:
|
| 1918 | + case 3: // Forced windowed modes
|
| 1919 | + primaryx = internalx = screenx = dwWidth;
|
| 1920 | + primaryy = internaly = screeny = dwHeight;
|
| 1921 | + internalbpp = screenbpp = dwBPP;
|
| 1922 | + if (dwRefreshRate) internalrefresh = primaryrefresh = screenrefresh = dwRefreshRate;
|
| 1923 | + else internalrefresh = primaryrefresh = screenrefresh = currmode.dmDisplayFrequency;
|
| 1924 | + primarybpp = dwBPP;
|
| 1925 | + InitGL(screenx, screeny, screenbpp, true, internalrefresh, hWnd, this, devwnd);
|
| 1926 | + glRenderer_SetBPP(this->renderer, primarybpp);
|
| 1927 | + primarylost = true;
|
| 1928 | + TRACE_EXIT(23, DD_OK);
|
| 1929 | + return DD_OK;
|
| 1930 | + break;
|
1910 | 1931 | }
|
1911 | 1932 | TRACE_EXIT(23,DDERR_GENERIC);
|
1912 | 1933 | ERR(DDERR_GENERIC);
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -145,11 +145,31 @@ |
146 | 146 | This->start = CreateEvent(NULL,FALSE,FALSE,NULL);
|
147 | 147 | if(fullscreen)
|
148 | 148 | {
|
149 | | - winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
|
150 | | - winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
|
151 | | - SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
|
152 | | - SetWindowLongPtrA(This->hWnd, GWL_STYLE, (winstyle | WS_POPUP | WS_SYSMENU) & ~(WS_CAPTION | WS_THICKFRAME));
|
153 | | - ShowWindow(This->hWnd,SW_MAXIMIZE);
|
| 149 | + switch (dxglcfg.fullmode)
|
| 150 | + {
|
| 151 | + case 0:
|
| 152 | + case 1: // Fullscreen
|
| 153 | + winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
|
| 154 | + winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
|
| 155 | + SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
|
| 156 | + SetWindowLongPtrA(This->hWnd, GWL_STYLE, (winstyle | WS_POPUP | WS_SYSMENU) & ~(WS_CAPTION | WS_THICKFRAME));
|
| 157 | + ShowWindow(This->hWnd, SW_MAXIMIZE);
|
| 158 | + break;
|
| 159 | + case 2: // Windowed
|
| 160 | + winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
|
| 161 | + winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
|
| 162 | + SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex | WS_OVERLAPPEDWINDOW);
|
| 163 | + SetWindowLongPtrA(This->hWnd, GWL_STYLE, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX));
|
| 164 | + ShowWindow(This->hWnd, SW_MAXIMIZE);
|
| 165 | + break;
|
| 166 | + case 3: // Windowed resizable
|
| 167 | + winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
|
| 168 | + winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
|
| 169 | + SetWindowLongPtrA(This->hWnd, GWL_EXSTYLE, winstyleex | WS_OVERLAPPEDWINDOW);
|
| 170 | + SetWindowLongPtrA(This->hWnd, GWL_STYLE, winstyle | WS_OVERLAPPEDWINDOW);
|
| 171 | + ShowWindow(This->hWnd, SW_MAXIMIZE);
|
| 172 | + break;
|
| 173 | + }
|
154 | 174 | }
|
155 | 175 | if(width)
|
156 | 176 | {
|
— | — | @@ -392,12 +412,55 @@ |
393 | 413 | */
|
394 | 414 | void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd)
|
395 | 415 | {
|
| 416 | + RECT wndrect;
|
| 417 | + int screenx, screeny;
|
| 418 | + LONG_PTR winstyle, winstyleex;
|
396 | 419 | EnterCriticalSection(&This->cs);
|
397 | 420 | if(fullscreen && newwnd)
|
398 | 421 | {
|
399 | | - SetWindowLongPtrA(newwnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
|
400 | | - SetWindowLongPtrA(newwnd,GWL_STYLE,WS_OVERLAPPED);
|
401 | | - ShowWindow(newwnd,SW_MAXIMIZE);
|
| 422 | + switch (dxglcfg.fullmode)
|
| 423 | + {
|
| 424 | + case 0:
|
| 425 | + case 1: // Fullscreen
|
| 426 | + winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
|
| 427 | + winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
|
| 428 | + SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex & ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE));
|
| 429 | + SetWindowLongPtrA(newwnd, GWL_STYLE, (winstyle | WS_POPUP | WS_SYSMENU) & ~(WS_CAPTION | WS_THICKFRAME));
|
| 430 | + ShowWindow(newwnd, SW_MAXIMIZE);
|
| 431 | + break;
|
| 432 | + case 2: // Windowed
|
| 433 | + winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
|
| 434 | + winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
|
| 435 | + SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex | WS_OVERLAPPEDWINDOW);
|
| 436 | + SetWindowLongPtrA(newwnd, GWL_STYLE, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX));
|
| 437 | + ShowWindow(newwnd, SW_NORMAL);
|
| 438 | + screenx = GetSystemMetrics(SM_CXSCREEN);
|
| 439 | + screeny = GetSystemMetrics(SM_CYSCREEN);
|
| 440 | + wndrect.right = width;
|
| 441 | + wndrect.bottom = height;
|
| 442 | + wndrect.left = (screenx / 2) - (width / 2);
|
| 443 | + wndrect.top = (screeny / 2) - (height / 2);
|
| 444 | + AdjustWindowRect(&wndrect, (winstyle | WS_OVERLAPPEDWINDOW) & ~(WS_THICKFRAME | WS_MAXIMIZEBOX), FALSE);
|
| 445 | + SetWindowPos(newwnd, 0, wndrect.left, wndrect.top, wndrect.right,
|
| 446 | + wndrect.bottom, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
| 447 | + break;
|
| 448 | + case 3: // Windowed resizable
|
| 449 | + winstyle = GetWindowLongPtrA(newwnd, GWL_STYLE);
|
| 450 | + winstyleex = GetWindowLongPtrA(newwnd, GWL_EXSTYLE);
|
| 451 | + SetWindowLongPtrA(newwnd, GWL_EXSTYLE, winstyleex | WS_OVERLAPPEDWINDOW);
|
| 452 | + SetWindowLongPtrA(newwnd, GWL_STYLE, winstyle | WS_OVERLAPPEDWINDOW);
|
| 453 | + ShowWindow(newwnd, SW_NORMAL);
|
| 454 | + screenx = GetSystemMetrics(SM_CXSCREEN);
|
| 455 | + screeny = GetSystemMetrics(SM_CYSCREEN);
|
| 456 | + wndrect.right = width;
|
| 457 | + wndrect.bottom = height;
|
| 458 | + wndrect.left = (screenx / 2) - (width / 2);
|
| 459 | + wndrect.top = (screeny / 2) - (height / 2);
|
| 460 | + AdjustWindowRect(&wndrect, winstyle | WS_OVERLAPPEDWINDOW, FALSE);
|
| 461 | + SetWindowPos(newwnd, 0, wndrect.left, wndrect.top, wndrect.right,
|
| 462 | + wndrect.bottom, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
|
| 463 | + break;
|
| 464 | + }
|
402 | 465 | }
|
403 | 466 | This->inputs[0] = (void*)width;
|
404 | 467 | This->inputs[1] = (void*)height;
|