How do I check if the game is fullscreen / windowed

Godot Version

4.2.2

Question

I am trying to implement a fullscreen button function and I want it to check if the game is windowed or in fullscreen.
I dont know what function does that.
Here is my attempt:

	if Input.is_action_just_pressed("fullscreen") and DisplayServer.WINDOW_MODE_WINDOWED:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
	elif Input.is_action_just_pressed("fullscreen") and DisplayServer.WINDOW_MODE_FULLSCREEN:
		DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)

window_get_mode()

2 Likes

I have made a solution by making a variable (var = is_fullscreen) to work around the problem, but then I saw your answer and decided to change the code and it still works:

if Input.is_action_just_pressed("fullscreen") and DisplayServer.window_get_mode() == 0:
	DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
elif Input.is_action_just_pressed("fullscreen") and DisplayServer.window_get_mode() == 3:
	DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.