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

Fix OpenGL resizing #95

Merged
merged 3 commits into from
May 15, 2023
Merged

Fix OpenGL resizing #95

merged 3 commits into from
May 15, 2023

Conversation

Godnoken
Copy link
Contributor

@Godnoken Godnoken commented May 5, 2023

This PR will fix ImGui not resetting & thus disappearing in some games when a resize, resolution change or ALT + TAB happens.

We have to compare resolution because some older games (like CS 1.6) don't trigger any window resize when it is in fullscreen and the user changes resolution.

We have to compare window rect because ALT + TAB'ing and changing from windowed to/from fullscreen doesn't always trigger resolution change.


The only issue I have noticed so far is that after a bunch of resizes it is possible that everything ImGui renders goes completely black. If you resize again it is possible that it disappears.
I assume there is something more needed for the reset on the OpenGL end - maybe glClearColor?

image

@Godnoken
Copy link
Contributor Author

Godnoken commented May 5, 2023

Fixed everything turning black with glClearColor.

Almost tricked myself that it wasn't working because I kept rebuilding for x64 when the games I were trying it on are x86... 🤕

@Godnoken Godnoken marked this pull request as ready for review May 6, 2023 07:33
@Godnoken Godnoken requested a review from veeenu May 12, 2023 10:09
Copy link
Owner

@veeenu veeenu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Looks clean and consistent now. We can merge into main after a rebase.

On an unrelated note, I just noticed that IMGUI_RENDER is an Option<T> instead of OnceCell -- I might want to change that to be more consistent across the board and to not accidentally run into concurrency issues (I'm not sure what could be some side effects of using one or the other, but I do know). Can't wait for this to land into stable and do a pass over all of the other renderers too.

@Godnoken Godnoken force-pushed the fix-opengl-resizing branch from c1a9adf to 8856a12 Compare May 15, 2023 06:04
@Godnoken
Copy link
Contributor Author

On an unrelated note, I just noticed that IMGUI_RENDER is an Option<T> instead of OnceCell -- I might want to change that to be more consistent across the board and to not accidentally run into concurrency issues (I'm not sure what could be some side effects of using one or the other, but I do know). Can't wait for this to land into stable and do a pass over all of the other renderers too.

Yup, noticed that. There are quite a few inconsistencies across the renderers and hooks, not that it is surprising, but definitely may be worth looking at more closely.

Didn't even notice that OnceCell isn't thread-safe.

@veeenu veeenu merged commit 28d77d8 into veeenu:main May 15, 2023
@veeenu
Copy link
Owner

veeenu commented May 15, 2023

Yup, noticed that. There are quite a few inconsistencies across the renderers and hooks, not that it is surprising, but definitely may be worth looking at more closely.

Yeah, now that I have quite a bit of experience with renderers and hooks under my belt I want to do a full refactor of all of that code eventually, likely once we're able to have more confidence in windows-rs again (as per my comments on #98).

Didn't even notice that OnceCell isn't thread-safe.

It's not a big deal for us since currently we either use that with immutable data structures or wrap Mutexes in there, but the fewer data types the better, in my opinion, and switching to OnceLock is something I see as desirable eventually as then you don't have to manage that stuff manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants