setup_egl_display sdl_window.wm_info.display_handle
if debug_gamnit then print "Setting up EGL context"
- select_egl_config(red_bits, green_bits, blue_bits, 8, 8, 0, 0)
+ select_egl_config(red_bits, green_bits, blue_bits, 8, 8, 0)
setup_egl_context sdl_window.wm_info.window_handle
end
print_error "Failed to initialize SDL2 IMG: {sdl.error}"
end
- var sdl_window = new SDLWindow(window_title.to_cstring, window_width, window_height, (new SDLWindowFlags).opengl)
+ var sdl_window = new SDLWindow(window_title.to_cstring, window_width, window_height, sdl_window_flags)
assert not sdl_window.address_is_null else
print_error "Failed to create SDL2 window: {sdl.error}"
end
# Audio support
var inited = mix.initialize(mix_init_flags)
- assert inited != mix_init_flags else
+ if inited != mix_init_flags then
print_error "Failed to load SDL2 mixer format supports: {mix.error}"
end
- var opened = mix.open_audio(44100, mix.default_format, 2, 1024)
- assert opened else
+ var open = mix.open_audio(44100, mix.default_format, 2, 1024)
+ if not open then
print_error "Failed to initialize SDL2 mixer: {mix.error}"
end
return sdl_window
end
- # Initialization flags passed to SDL2 mixer
+ # SDL2 window initialization flags
#
- # Defaults to all available formats.
- var mix_init_flags: MixInitFlags = mix.flac | mix.mod | mix.mp3 | mix.ogg is lazy, writable
+ # The default value supports OpenGL and window resizing.
+ var sdl_window_flags: SDLWindowFlags = (new SDLWindowFlags).opengl.resizable is lazy, writable
+
+ # SDL2 mixer initialization flags
+ #
+ # Defaults to FLAC, MP3 and OGG.
+ var mix_init_flags: MixInitFlags = mix.flac | mix.mp3 | mix.ogg is lazy, writable
# Close the SDL display
fun close_sdl
var pixels = surface.pixels
load_from_pixels(pixels, surface.w, surface.h, format)
+
+ surface.free
end
end