You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
Added OS::center_window to center the window precisely on desktop platforms
This commit is contained in:
committed by
Marcelo Fernandez
parent
7983fb95b0
commit
129e0f34d0
@@ -546,6 +546,17 @@ Dictionary OS::get_engine_version() const {
|
||||
return dict;
|
||||
}
|
||||
|
||||
void OS::center_window() {
|
||||
|
||||
if (is_window_fullscreen()) return;
|
||||
|
||||
Size2 scr = get_screen_size(get_current_screen());
|
||||
Size2 wnd = get_real_window_size();
|
||||
int x = scr.width / 2 - wnd.width / 2;
|
||||
int y = scr.height / 2 - wnd.height / 2;
|
||||
set_window_position(Vector2(x, y));
|
||||
}
|
||||
|
||||
OS::OS() {
|
||||
last_error = NULL;
|
||||
frames_drawn = 0;
|
||||
|
||||
Reference in New Issue
Block a user