@@ -21,20 +21,23 @@ class Screen
2121 #
2222 # @param [Integer] w
2323 # @param [Integer] h
24- def initialize ( w , h )
24+ # @param [Boolean] fullscreen
25+ def initialize ( w , h , fullscreen = true )
2526 @scale = 1.0
2627 @logger = Moon ::ContextLogger . new ( STDERR , 'Screen' )
28+ @fullscreen = fullscreen
2729 create_window w , h
2830 initialize_renderer
2931 initialize_clear_color
30- initialize_screen_size
32+ initialize_screen_size if ! fullscreen?
3133 @vsync = true
3234 end
3335
3436 # Creates the internal window
3537 #
3638 # @param [Integer] w width of the window
3739 # @param [Integer] h height of the window
40+ # @param [Boolean] fullscreen
3841 def create_window ( w , h )
3942 @logger . debug "Creating Window: w=#{ w } h=#{ h } "
4043 GLFW . window_hint GLFW ::RESIZABLE , GL2 ::GL_FALSE
@@ -44,9 +47,11 @@ def create_window(w, h)
4447 GLFW . window_hint GLFW ::OPENGL_PROFILE , GLFW ::OPENGL_CORE_PROFILE # for 3.0 and on
4548 Moon ::Shader . is_legacy = false
4649
50+ monitor = GLFW . primary_monitor if fullscreen?
51+
4752 title = 'Moon Player'
4853 begin
49- @window = GLFW ::Window . new w , h , title
54+ @window = GLFW ::Window . new w , h , title , monitor
5055 @logger . warn "3.3 Window Created"
5156 rescue GLFWError
5257 @logger . warn "Failed to obtain 3.3 context, falling back to 2.1"
@@ -55,7 +60,7 @@ def create_window(w, h)
5560 GLFW . window_hint GLFW ::CONTEXT_VERSION_MINOR , 1
5661 Moon ::Shader . is_legacy = true
5762
58- @window = GLFW ::Window . new w , h , title
63+ @window = GLFW ::Window . new w , h , title , monitor
5964 @logger . warn "2.1 Window Created"
6065 end
6166 end
@@ -99,6 +104,11 @@ def should_close?
99104 @window . should_close?
100105 end
101106
107+ # Is the window currently fullscreen?
108+ def fullscreen?
109+ @fullscreen
110+ end
111+
102112 # Swaps buffers, call this once per frame
103113 def swap
104114 @window . swap_buffers
0 commit comments