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 window resize/maximize #2

Open
Raptor007 opened this issue Oct 19, 2024 · 2 comments
Open

Fix window resize/maximize #2

Raptor007 opened this issue Oct 19, 2024 · 2 comments
Assignees
Milestone

Comments

@Raptor007
Copy link
Owner

Resizing or maximizing the window seems to miss the SDL2 event(s) that should signal the game to resize its contents.

It might also be nice for the maximize button and/or alt+enter to toggle fullscreen mode.

@Raptor007 Raptor007 added this to the v0.9.9 milestone Oct 19, 2024
@Raptor007
Copy link
Owner Author

You can work around this bug in the console or settings.cfg.
To change window size:

g_res_windowed_x 1920
g_res_windowed_y 1080
g_restart

To change to fullscreen mode:

g_fullscreen true
g_restart

@Raptor007 Raptor007 self-assigned this Oct 20, 2024
@Raptor007
Copy link
Owner Author

Raptor007 commented Oct 20, 2024

The problem is here: https://github.com/Raptor007/RaptorEngine/blob/master/Core/RaptorGame.cpp#L392

if( event.type == SDL_WINDOWEVENT_RESIZED )
	Gfx.SetMode( event.window.data1, event.window.data2 );

Apparently SDL_WINDOWEVENT_RESIZED is a window event subtype, not an event type, so it never matched.
New code for BTTT v0.9.9:

if( event.type == SDL_WINDOWEVENT )
{
	if( (event.window.event == SDL_WINDOWEVENT_RESIZED) && ! Gfx.Fullscreen )
		Gfx.SetMode( event.window.data1, event.window.data2 );
	else if( (event.window.event == SDL_WINDOWEVENT_MAXIMIZED) && Cfg.SettingAsBool("g_maximize_fullscreen") )
		Gfx.SetMode( 0, 0, Gfx.BPP, true, Gfx.FSAA, Gfx.AF, Gfx.ZBits );
}

Also, since SDL2 does not destroy the OpenGL context upon window resize, I've patched Graphics::SetMode( x, y ) so it'll just change the resolution-related variables without restarting graphics.

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

No branches or pull requests

1 participant