@@ -162,6 +162,15 @@ function standard_window_hints()
162
162
(GLFW. AUX_BUFFERS, 0 )
163
163
]
164
164
end
165
+
166
+
167
+ full_screen_usage_message () = """
168
+ Keyword arg fullscreen accepts:
169
+ Integer: The number of the Monitor to Select
170
+ Bool: if true, primary monitor gets fullscreen, false no fullscren (default)
171
+ GLFW.Monitor: Fullscreens on the passed monitor
172
+ """
173
+
165
174
"""
166
175
Function to create a pure GLFW OpenGL window
167
176
"""
@@ -174,7 +183,8 @@ function create_glcontext(
174
183
windowhints = standard_window_hints (),
175
184
contexthints = standard_context_hints (major, minor),
176
185
visible = true ,
177
- focus = false
186
+ focus = false ,
187
+ fullscreen = false
178
188
)
179
189
# we create a new context, so we need to clear the shader cache.
180
190
# TODO , cache shaders in GLAbstraction per GL context
@@ -195,7 +205,30 @@ function create_glcontext(
195
205
end
196
206
end
197
207
GLFW. WindowHint (GLFW. OPENGL_DEBUG_CONTEXT, Cint (debugging))
208
+ monitor = if fullscreen != nothing
209
+ if isa (fullscreen, GLFW. Monitor)
210
+ monitor
211
+ elseif isa (fullscreen, Bool)
212
+ fullscreen ? GLFW. GetPrimaryMonitor () : GLFW. Monitor (C_NULL )
213
+ elseif isa (fullscreen, Integer)
214
+ GLFW. GetMonitors ()[fullscreen]
215
+
216
+ else
217
+ error (string (
218
+ " Usage Error. Keyword argument fullscreen has value: $fullscreen .\n " ,
219
+ full_screen_usage_message ()
220
+ ))
221
+ end
222
+ else
223
+ GLFW. Monitor (C_NULL )
224
+ end
198
225
window = GLFW. CreateWindow (resolution... , String (name))
226
+ if monitor != GLFW. Monitor (C_NULL )
227
+ GLFW. SetKeyCallback (window, (_1, button, _2, _3, _4) -> begin
228
+ button == GLFW. KEY_ESCAPE && GLWindow. make_windowed! (window)
229
+ end )
230
+ GLWindow. make_fullscreen! (window)
231
+ end
199
232
GLFW. MakeContextCurrent (window)
200
233
# tell GLAbstraction that we created a new context.
201
234
# This is important for resource tracking
@@ -205,6 +238,19 @@ function create_glcontext(
205
238
window
206
239
end
207
240
241
+ make_fullscreen! (screen:: Screen , monitor:: GLFW.Monitor = GLFW. GetPrimaryMonitor ()) = make_fullscreen! (nativewindow (screen), monitor)
242
+ function make_fullscreen! (window:: GLFW.Window , monitor:: GLFW.Monitor = GLFW. GetPrimaryMonitor ())
243
+ vidmodes = GLFW. GetVideoModes (monitor)[end ]
244
+ GLFW. SetWindowMonitor (window, monitor, 0 , 0 , vidmodes. width, vidmodes. height, GLFW. DONT_CARE)
245
+ return
246
+ end
247
+
248
+ make_windowed! (screen:: Screen ) = make_windowed! (nativewindow (screen))
249
+ function make_windowed! (window:: GLFW.Window )
250
+ width, height = standard_screen_resolution ()
251
+ GLFW. SetWindowMonitor (window, GLFW. Monitor (C_NULL ), 0 , 0 , width, height, GLFW. DONT_CARE)
252
+ return
253
+ end
208
254
209
255
"""
210
256
Most basic Screen constructor, which is usually used to create a parent screen.
@@ -230,7 +276,8 @@ function Screen(name = "GLWindow";
230
276
stroke = (0f0 , color),
231
277
hidden = false ,
232
278
visible = true ,
233
- focus = false
279
+ focus = false ,
280
+ fullscreen = false
234
281
)
235
282
# create glcontext
236
283
@@ -239,7 +286,8 @@ function Screen(name = "GLWindow";
239
286
resolution = resolution, debugging = debugging,
240
287
major = major, minor = minor,
241
288
windowhints = windowhints, contexthints= contexthints,
242
- visible = visible, focus = focus
289
+ visible = visible, focus = focus,
290
+ fullscreen = fullscreen
243
291
)
244
292
# create standard signals
245
293
signal_dict = register_callbacks (window, callbacks)
0 commit comments