Skip to content

Commit

Permalink
Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
crosire committed Feb 12, 2023
1 parent ec01046 commit bf3a322
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
6 changes: 3 additions & 3 deletions source/d3d8to9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ extern "C" IDirect3D8 *WINAPI Direct3DCreate8(UINT SDKVersion)
LOG << "Failed to load d3dx9_43.dll! Some features will not work correctly." << std::endl;
#endif
if (MessageBox(nullptr, TEXT(
"Failed to load d3dx9_43.dll! Some features will not work correctly.\n\n"
"It's required to install the \"Microsoft DirectX End-User Runtime\" in order to use d3d8to9.\n\n"
"Please click \"OK\" to open the official download page or \"CANCEL\" to continue anyway."), nullptr, MB_ICONWARNING | MB_TOPMOST | MB_SETFOREGROUND | MB_OKCANCEL | MB_DEFBUTTON1) == IDOK)
"Failed to load d3dx9_43.dll! Some features will not work correctly.\n\n"
"It's required to install the \"Microsoft DirectX End-User Runtime\" in order to use d3d8to9.\n\n"
"Please click \"Ok\" to open the official download page or \"CANCEL\" to continue anyway."), nullptr, MB_ICONWARNING | MB_TOPMOST | MB_SETFOREGROUND | MB_OKCANCEL | MB_DEFBUTTON1) == IDOK)
{
ShellExecute(nullptr, TEXT("open"), TEXT("https://www.microsoft.com/download/details.aspx?id=35"), nullptr, nullptr, SW_SHOW);

Expand Down
27 changes: 17 additions & 10 deletions source/d3d8types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,41 +131,48 @@ void ConvertPresentParameters(D3DPRESENT_PARAMETERS8 &Input, D3DPRESENT_PARAMETE
Output.Flags = Input.Flags;

// MultiSampleType must be D3DMULTISAMPLE_NONE unless SwapEffect has been set to D3DSWAPEFFECT_DISCARD or if there is a lockable backbuffer
if (Output.SwapEffect != D3DSWAPEFFECT_DISCARD || (Output.Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER))
if (Input.SwapEffect != D3DSWAPEFFECT_DISCARD || (Input.Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER))
{
Output.MultiSampleType = D3DMULTISAMPLE_NONE;
}

if (Input.Windowed)
{
Output.FullScreen_RefreshRateInHz = 0;

// D3D8 always presents without waiting for vblank when windowed
Output.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
}
else
{
Output.FullScreen_RefreshRateInHz = Input.FullScreen_RefreshRateInHz;

// D3DPRESENT_RATE_UNLIMITED is no longer supported in D3D9
if (Input.FullScreen_RefreshRateInHz == D3DPRESENT_RATE_UNLIMITED)
{
Output.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
}
else
{
Output.FullScreen_RefreshRateInHz = Input.FullScreen_RefreshRateInHz;
}

// D3DPRESENT_INTERVAL_DEFAULT is equivalent to D3DPRESENT_INTERVAL_ONE in D3D9
Output.PresentationInterval = Input.FullScreen_PresentationInterval;
}

// D3DSWAPEFFECT_COPY_VSYNC is no longer supported in D3D9
if (Output.SwapEffect == D3DSWAPEFFECT_COPY_VSYNC)
if (Input.SwapEffect == D3DSWAPEFFECT_COPY_VSYNC)
{
Output.SwapEffect = D3DSWAPEFFECT_COPY;
Output.SwapEffect = D3DSWAPEFFECT_COPY;

// Need to wait for vblank before copying (both when windowed and full-screen)
if (Output.PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE)
if (Input.Windowed)
{
Output.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
else
{
Output.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
// As per documentation the D3DPRESENT_INTERVAL_IMMEDIATE flag is meaningless when used in conjunction with D3DSWAPEFFECT_COPY_VSYNC
if (Input.FullScreen_PresentationInterval == D3DPRESENT_INTERVAL_IMMEDIATE)
{
Output.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
}
}
}
Expand Down

0 comments on commit bf3a322

Please sign in to comment.