尝试按照通常的方式调整 D3DPRESENT_PARAMETERS。就像是:
// D3DPRESENT_PARAMETERS is already defined as md3dPP
RECT R ={0, 0, 640, 480}
AdjustwindowRect(&R, WS_OVERLAPPEDWINDOW, false);
md3dPP.BackBufferFormat = D3DFMT_UNKNOWN;
md3dPP.BackBufferWidth = 640;
md3dPP.BackBufferHeight = 480;
md3dPP.Windowed = true;
如果您愿意,这也可能是更改窗口样式的好时机,例如:
SetWindowLongPtr(yourWindowHandle, GWL_STYLE, WS_OVERLAPPEDWINDOW)
// must use SetWindowPos for SetWindowLongPtr changes to take effect
SetWindowPos(yourWindowHandle, HWND_TOP, 100, 100, R.right, R.bottom, SWP_NOZORDER | SWP_SHOWWINDOW);
或者,如果您使用全屏:
md3dPP.BackBufferFormat = D3DFMT_X8R8G8B8;
md3dPP.BackBufferWidth = 640;
md3dPP.BackBufferHeight = 480;
md3dPP.Windowed = true;
SetWindowLongPtr(yourWindowHandle, GWL_STYLE, WS_POPUP)
// must use SetWindowPos for SetWindowLongPtr changes to take effect
SetWindowPos(yourWindowHandle, HWND_TOP, 0, 0, 640, 480, SWP_NOZORDER | SWP_SHOWWINDOW);
无论哪种方式,通过调用 IDirect3DDevice9::Reset 来跟进。只需确保在重置时重新初始化资源。
所以如果你定义了类似的东西: IDirect3DDevice9 *gd3dDevice;
采用:
gd3dDevice->Reset(&md3dPP);