Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DX9] Some games do not reset at window resizing #103

Open
Godnoken opened this issue May 24, 2023 · 0 comments
Open

[DX9] Some games do not reset at window resizing #103

Godnoken opened this issue May 24, 2023 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@Godnoken
Copy link
Contributor

  • Warhammer 40K: Dawn of War; Displays ImGui fine if injected on launch, but if you change resolution in-game then ImGui disappears due to no trigger of a device reset.
  • Heroes of Might & Magic 5; If injected on launch, ImGui doesn't show up & resolution change doesn't trigger device reset

The solution could be to save the previous size & check if it changes on each frame. Since we already call get_window_rect, hopefully that is enough, but it could very well be so that the device's viewport needs to be checked as well like in the OpenGL solution.

Since this is a fairly isolated thing, I'm wondering - Is the overhead of checking the viewport basically non-existent or is it something that has to be considered?


There is also another game (don't remember which one) with a similar issue. Might even have been a DirectDraw game that I ran with dxwrapper, so I'm not too sure of the relevancy here since it may be so that there is no equivalent to Reset in those games.

The only solution I could come up with was to read for calls to WM_ACTIVATEAPP and subsequently reset the device manually from there.

 WM_ACTIVATEAPP => {
            if let Some(device) = D3D9DEVICE.get() {
                let mut present_params = D3DPRESENT_PARAMETERS {
                    Windowed: BOOL(1),
                    SwapEffect: D3DSWAPEFFECT_DISCARD,
                    BackBufferFormat: D3DFMT_UNKNOWN,
                    ..core::mem::zeroed()
                };
                device.Reset(&mut present_params).unwrap();
            }
        }

It's not the prettiest solution & would require us to expose the device somehow like talked about in #80

@veeenu veeenu added the help wanted Extra attention is needed label Aug 19, 2023
This was referenced Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants