note
	description: "A GAME_WINDOW that can be used directly with OpenGL."
	author: "Louis Marchand"
	date: "Tue, 29 Dec 2015 19:06:42 +0000"
	revision: "1.0"

class 
	GAME_WINDOW_GL

create 
	make

feature {NONE} -- Initialization

	default_create
			-- Process instances of classes with no creation clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	make (a_title: READABLE_STRING_GENERAL; a_display: detachable GAME_DISPLAY; a_is_x_centered, a_is_y_centered, a_is_x_undefined, a_is_y_undefined: BOOLEAN; a_x, a_y, a_width, a_height: INTEGER_32; a_flags: NATURAL_32)
			-- Initialization of a a_widthxa_height Current at position
			-- (a_x,a_y) using a_title as window caption, and
			-- using a_flags as internal attributes flags. If a_is_x_centered
			-- or a_is_y_centered are set, the position will be centered on
			-- a_display. If a_is_x_undefined or a_is_y_undefined are
			-- set, the position does not matter, but will be place on a_display
			-- If a_display is Void, the first found display will be used.
		require -- from GAME_WINDOW
			game_screen_video_enabled: Game_library.is_video_enable
			centered_or_undefine_x: a_is_x_centered implies not a_is_x_undefined
			centered_or_undefine_y: a_is_y_centered implies not a_is_y_undefined
			width_valid: a_width > 0
			height_valid: a_height > 0
		do
			Precursor {GAME_WINDOW} (a_title, a_display, a_is_x_centered, a_is_y_centered, a_is_x_undefined, a_is_y_undefined, a_x, a_y, a_width, a_height, a_flags)
			gl_context := {GAME_SDL_EXTERNAL}.sdl_gl_createcontext (item)
			manage_error_pointer (gl_context, "Cannot create GL context for the Window")
		ensure -- from GAME_WINDOW
			make_window_is_open: not has_error implies exists
		end
	
feature -- Access

	brightness: REAL_32 assign set_brightness
			-- The Gamma correction where 0.0 is completely dark and 1.0 is normal.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowbrightness (item)
		ensure -- from GAME_WINDOW
			window_brightness_not_changed: brightness = old brightness
		end

	center_horizontally
			-- Change x so that Current became centered in the screen
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_x ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered)
		end

	center_horizontally_on_display (a_display: GAME_DISPLAY)
			-- Change x so that Current became centered in the screen a_display
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			center_horizontally_on_display_index (a_display.index)
		end

	center_horizontally_on_display_index (a_index: INTEGER_32)
			-- Change x so that Current became centered in the screen number a_index
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
			index_valid: a_index >= 0 and a_index < Game_library.displays_count
		do
			set_x ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered_display (a_index))
		end

	center_on_display (a_display: GAME_DISPLAY)
			-- Change position so that Current became centered in the screen a_display
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			center_on_display_index (a_display.index)
		end

	center_on_display_index (a_index: INTEGER_32)
			-- Change position so that Current became centered in the screen number a_index
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
			index_valid: a_index >= 0 and a_index < Game_library.displays_count
		do
			set_position ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered_display (a_index), {GAME_SDL_EXTERNAL}.sdl_windowpos_centered_display (a_index))
		end

	center_position
			-- Change position so that Current became centered on the screen
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_position ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered, {GAME_SDL_EXTERNAL}.sdl_windowpos_centered)
		end

	center_vertically
			-- Change y so that Current became centered in the screen
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_y ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered)
		end

	center_vertically_on_display (a_display: GAME_DISPLAY)
			-- Change y so that Current became centered in the screen a_display
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			center_vertically_on_display_index (a_display.index)
		end

	center_vertically_on_display_index (a_index: INTEGER_32)
			-- Change y so that Current became centered in the screen number a_index
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
			index_valid: a_index >= 0 and a_index < Game_library.displays_count
		do
			set_y ({GAME_SDL_EXTERNAL}.sdl_windowpos_centered_display (a_index))
		end

	clear_events
			-- Remove all events.
			-- (from GAME_WINDOW_EVENTS)
		local
			l_was_running: BOOLEAN
		do
			l_was_running := is_events_running
			if is_events_running then
				stop_events
			end
			show_actions_internal := Void
			hide_actions_internal := Void
			expose_actions_internal := Void
			move_actions_internal := Void
			resize_actions_internal := Void
			size_change_actions_internal := Void
			minimize_actions_internal := Void
			maximize_actions_internal := Void
			restore_actions_internal := Void
			mouse_enter_actions_internal := Void
			mouse_leave_actions_internal := Void
			keyboard_focus_gain_actions_internal := Void
			keyboard_focus_lost_actions_internal := Void
			close_request_actions_internal := Void
			key_pressed_actions_internal := Void
			key_released_actions_internal := Void
			text_editing_actions_internal := Void
			text_input_actions_internal := Void
			mouse_motion_actions_internal := Void
			mouse_button_pressed_actions_internal := Void
			mouse_button_released_actions_internal := Void
			mouse_wheel_move_actions_internal := Void
			if l_was_running then
				run_events
			end
		ensure -- from GAME_EVENTS
			running_unchanged: is_events_running = old is_events_running
		end

	clipboard_text: READABLE_STRING_GENERAL assign set_clipboard_text
			-- The text contained by the system clipboard
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			has_text: has_clipboard_text
		local
			l_converter: UTF_CONVERTER
			l_c_pointer: POINTER
			l_c_string: C_STRING
		do
			clear_error
			l_c_pointer := {GAME_SDL_EXTERNAL}.sdl_getclipboardtext
			if not l_c_pointer.is_default_pointer then
				create l_c_string.make_shared_from_pointer (l_c_pointer)
				Result := l_converter.utf_8_string_8_to_string_32 (l_c_string.string)
				{GAME_SDL_EXTERNAL}.sdl_free (l_c_pointer)
			else
				manage_error_pointer (l_c_pointer, "Cannot fetch clipboard text.")
				Result := ""
			end
		end

	close
			-- Close Current (you cannot open it again).
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			clear_events
			{GAME_SDL_EXTERNAL}.sdl_destroywindow (item)
			item := create {POINTER}.default_create;
			Game_library.internal_windows.prune_all (Current)
		end

	close_request_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When the Window manager request that Current be closed.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached close_request_actions_internal as la_close_request_actions_internal then
				Result := la_close_request_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				close_request_actions_internal := Result
			end
		end

	display: GAME_DISPLAY
			-- display containing the center of the window.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_index: INTEGER_32
		do
			l_index := display_index
			if l_index >= 0 then
				create Result.make (l_index)
			else
				create Result.make (0)
			end
		end

	display_index: INTEGER_32
			-- Index of the display containing the center of the window.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			clear_error
			has_error := False
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowdisplayindex (item)
			manage_error_code (Result, "An error occured when getting the display index.")
		ensure -- from GAME_WINDOW
			window_display_index_valid: not has_error implies Result >= 0
		end

	display_mode: GAME_DISPLAY_MODE assign set_display_mode
			-- The display mode of Current in fullscreen mode
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_error: INTEGER_32
		do
			create Result.make (1, 1)
			l_error := {GAME_SDL_EXTERNAL}.sdl_getwindowdisplaymode (item, Result.item)
			manage_error_code (l_error, "Cannot retreive the display mode of a window.")
		end

	events_controller: GAME_EVENTS_CONTROLLER
			-- The main event manager
			-- (from GAME_WINDOW)
		do
			Result := Game_library.events_controller
		end

	exists: BOOLEAN
			-- Is Current has been closed
			-- (from GAME_WINDOW)
		do
			Result := not item.is_default_pointer
		end

	expose_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current is exposed and should be redraw.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached expose_actions_internal as la_expose_actions_internal then
				Result := la_expose_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				expose_actions_internal := Result
			end
		end

	Game_library: GAME_LIBRARY_CONTROLLER
			-- The main controller of the game library
			-- (from GAME_LIBRARY_SHARED)
		once ("PROCESS")
			if attached internal_game_library as la_game_library then
				Result := la_game_library
			else
				create Result
			end
		end

	gamma_correction: TUPLE [red: ARRAYED_LIST [NATURAL_16]; green: ARRAYED_LIST [NATURAL_16]; blue: ARRAYED_LIST [NATURAL_16]]
			-- The gamma encoding of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_red, l_green, l_blue: ARRAY [NATURAL_16]
			l_error: INTEGER_32
		do
			create l_red.make_filled ({NATURAL_16} 0, 1, 256)
			create l_green.make_filled ({NATURAL_16} 0, 1, 256)
			create l_blue.make_filled ({NATURAL_16} 0, 1, 256)
			l_error := {GAME_SDL_EXTERNAL}.sdl_getwindowgammaramp (item, $l_red.to_pointer, $l_green.to_pointer, $l_blue.to_pointer)
			manage_error_code (l_error, "Cannot get gamma correction values.")
			Result := [create {ARRAYED_LIST [NATURAL_16]}.make_from_array (l_red), create {ARRAYED_LIST [NATURAL_16]}.make_from_array (l_green), create {ARRAYED_LIST [NATURAL_16]}.make_from_array (l_blue)]
		end

	generating_type: TYPE [detachable GAME_WINDOW_GL]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generating_type_not_void: Result /= Void
		end

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty
		end

	gl_accumulation_alpha_size: INTEGER_32
			-- Minimum number of bits for the alpha channel of the accumulation buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accum_alpha_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL accumulation buffer alpha channel size")
			Result := l_size
		end

	gl_accumulation_blue_size: INTEGER_32
			-- Minimum number of bits for the blue channel of the accumulation buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accum_blue_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL accumulation buffer blue channel size")
			Result := l_size
		end

	gl_accumulation_green_size: INTEGER_32
			-- Minimum number of bits for the green channel of the accumulation buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accum_green_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL accumulation buffer green channel size")
			Result := l_size
		end

	gl_accumulation_red_size: INTEGER_32
			-- Minimum number of bits for the red channel of the accumulation buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accum_red_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL accumulation buffer red channel size")
			Result := l_size
		end

	gl_alpha_size: INTEGER_32
			-- Minimum number of bits for the alpha channel of the color buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_alpha_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL alpha channel size")
			Result := l_size
		end

	gl_blue_size: INTEGER_32
			-- Minimum number of bits for the blue channel of the color buffer.
			-- Defaults to 2
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_blue_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL blue channel size")
			Result := l_size
		end

	gl_buffer_size: INTEGER_32
			-- Minimum number of bits for the frame buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_buffer_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL frame buffer size")
			Result := l_size
		end

	gl_context_valid: BOOLEAN
			-- The contex of Current is correctly created
		do
			Result := not gl_context.is_default_pointer
		end

	gl_depth_size: INTEGER_32
			-- Minimum number of bits for the depth buffer.
			-- Defaults to 16
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_depth_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL depth buffer size")
			Result := l_size
		end

	gl_drawable_size: TUPLE [width: INTEGER_32; height: INTEGER_32]
			-- Return the drawable area dimension of Current.
			-- Ti differ of size when we're rendering to a high-DPI drawable
			-- Note: use that with glViewport
		require
				gl_context_valid
		local
			l_width, l_height: INTEGER_32
		do
			{GAME_SDL_EXTERNAL}.sdl_gl_getdrawablesize (item, $l_width.to_pointer, $l_height.to_pointer)
			Result := [l_width, l_height]
		end

	gl_green_size: INTEGER_32
			-- Minimum number of bits for the green channel of the color buffer.
			-- Defaults to 3
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_green_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL green channel size")
			Result := l_size
		end

	gl_multi_sample_count: INTEGER_32
			-- If multisample anti-aliasing is enabled (see: is_gl_multi_sample_enabled),
			-- return the number of samples used around the current pixel
			-- Default: 0
		require
				gl_context_valid
				is_gl_multi_sample_enabled
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_multisamplesamples, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL multisample anti-aliasing information")
			Result := l_value
		end

	gl_red_size: INTEGER_32
			-- Minimum number of bits for the red channel of the color buffer.
			-- Defaults to 3
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_red_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL red channel size")
			Result := l_size
		end

	gl_stencil_size: INTEGER_32
			-- Minimum number of bits for the stencil buffer.
			-- Defaults to 0
		require
				gl_context_valid
		local
			l_error, l_size: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_stencil_size, $l_size.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL stencil buffer size")
			Result := l_size
		end

	gl_version: TUPLE [major: INTEGER_32; minor: INTEGER_32]
			-- The version of OpenGL that Current use.
			-- Default depend on the OpenGL library in the system
		require
				gl_context_valid
		local
			l_error: INTEGER_32
			l_major, l_minor: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_context_major_version, $l_major.to_pointer)
			if l_error = 0 then
				l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_context_minor_version, $l_minor.to_pointer)
				if l_error = 0 then
					Result := [l_major, l_minor]
				else
					manage_error_code (l_error, "Could not get the OpenGL minor version")
					Result := [l_major, 0]
				end
			else
				manage_error_code (l_error, "Could not get the OpenGL major version")
				Result := [0, 0]
			end
		end

	grab_input
			-- Force every input in Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowgrab (item, True)
		ensure -- from GAME_WINDOW
			is_grabbed: is_input_grabbed
		end

	has_border: BOOLEAN
			-- Is Current has border decoration
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_borderless) = 0
		end

	has_clipboard_text: BOOLEAN
			-- True if the system clipboard has some text
			-- (from GAME_WINDOW)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_hasclipboardtext
		end

	has_error: BOOLEAN
			-- Is the library has generate an error
			-- (from GAME_ERROR_MANAGER)

	has_input_focus: BOOLEAN
			-- Is Current having the focus for keyboard input
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_input_focus) /= 0
		end

	has_mouse_focus: BOOLEAN
			-- Is Current having the focus of the mouse
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_mouse_focus) /= 0
		end

	has_text_input: BOOLEAN
			-- Is Current in text input mode (see: start_text_input)
			-- (from GAME_WINDOW)
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_istextinputactive
		end

	height: INTEGER_32 assign set_height
			-- The vertical length of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := size.height
		end

	hide
			-- Remove the visibility of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_hidewindow (item)
		end

	hide_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current is hide.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached hide_actions_internal as la_hide_actions_internal then
				Result := la_hide_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				hide_actions_internal := Result
			end
		end

	id: NATURAL_32
			-- The internal identifier of the Window (For logging purpose)
			-- (from GAME_WINDOW)
		require -- from  GAME_WINDOW_EVENTS
			True
		require else -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowid (item)
		end

	is_fake_fullscreen: BOOLEAN assign set_is_fake_fullscreen
			-- Is Current in fullscreen mode
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_fullscreen_desktop) /= 0
		end

	is_foreign: BOOLEAN
			-- Is Current not created by the present library
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_foreign) /= 0
		end

	is_fullscreen: BOOLEAN assign set_is_fullscreen
			-- Is Current in fullscreen mode
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_fullscreen) /= 0
		end

	is_gl_compatibility_profile_enabled: BOOLEAN
			-- True to enable the compatibility context profile.
			-- In this profile, deprecated conext funtionnalities will be enabled;
			-- Default: Depend on the system
		require
				gl_context_valid
		do
			Result := gl_context_profile_flags = {GAME_SDL_EXTERNAL}.sdl_gl_context_profile_compatibility
		end

	is_gl_context_sharing_enabled: BOOLEAN
			-- True to enable OpenGL Context Sharing
			-- Default: False
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_share_with_current_context, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL context sharing information")
			Result := l_value /= 0
		end

	is_gl_core_profile_enabled: BOOLEAN
			-- True to enable the core context profile.
			-- In this profile, deprecated conext funtionnalities will be disabled;
			-- Default: Depend on the system
		require
				gl_context_valid
		do
			Result := gl_context_profile_flags = {GAME_SDL_EXTERNAL}.sdl_gl_context_profile_core
		end

	is_gl_debug_enabled: BOOLEAN
			-- Put the GL into a "debug" mode. May cause performance lost
			-- Ignored on system that does not support it.
			-- Default: False
		require
				gl_context_valid
		do
			Result := gl_context_flags.bit_and ({GAME_SDL_EXTERNAL}.sdl_gl_context_debug_flag) /= 0
		end

	is_gl_double_buffer_enabled: BOOLEAN
			-- True if Current is double buffered. False if not.
			-- Default: True
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_doublebuffer, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL double buffer information")
			Result := l_value /= 0
		end

	is_gl_es_profile_enabled: BOOLEAN
			-- True to enable the GLES context profile.
			-- In this profile, only the GLES subset of the context functionnalities will be enabled
			-- Default: Depend on the system
		require
				gl_context_valid
		do
			Result := gl_context_profile_flags = {GAME_SDL_EXTERNAL}.sdl_gl_context_profile_es
		end

	is_gl_forward_compatibility_enabled: BOOLEAN
			-- If True, no deprecated context functionality will be supported
			-- Can cause a performance gain
			-- Only available for OpenGL 3.0 and newer
			-- Ignored on system that does not support it.
			-- Default: False
		require
				gl_context_valid
		do
			Result := gl_context_flags.bit_and ({GAME_SDL_EXTERNAL}.sdl_gl_context_forward_compatible_flag) /= 0
		end

	is_gl_hardware_rendering_enable: BOOLEAN
			-- Current uses hardware rendering.
			-- Default: True
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accelerated_visual, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL software rendering information")
			Result := l_value = 0
		end

	is_gl_multi_sample_enabled: BOOLEAN
			-- True if Current used multisample anti-aliasing. False if not
			-- Default: False
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_multisamplebuffers, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL multisample anti-aliasing information")
			Result := l_value /= 0
		end

	is_gl_reset_isolation_enabled: BOOLEAN
			-- True to enable more rebust driver or hardware failure reset management.
			-- Ignored on system that does not support it.
			-- Default: False
		require
				gl_context_valid
		do
			Result := gl_context_flags.bit_and ({GAME_SDL_EXTERNAL}.sdl_gl_context_reset_isolation_flag) /= 0
		end

	is_gl_robust_access_enabled: BOOLEAN
			-- If True, Internal OpenGL context will use more robust API.
			-- Ignored on system that does not support it.
			-- Can cause a performance lost
			-- Default: False
		require
				gl_context_valid
		do
			Result := gl_context_flags.bit_and ({GAME_SDL_EXTERNAL}.sdl_gl_context_robust_access_flag) /= 0
		end

	is_gl_software_rendering_enable: BOOLEAN
			-- Current uses software rendering.
			-- Default: False
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_accelerated_visual, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL software rendering information")
			Result := l_value = 0
		end

	is_gl_srgb_request_enabled: BOOLEAN
			-- True to request sRGB rendering
			-- Default: False
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_framebuffer_srgb_capable, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL sRGB rendering request information")
			Result := l_value /= 0
		end

	is_gl_stereo_enabled: BOOLEAN
			-- True if Current used quad buffer stereo rendering. False if not.
			-- Default: False
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_stereo, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL quad buffer stereo rendering information")
			Result := l_value /= 0
		end

	is_hidden: BOOLEAN assign set_is_hidden
			-- Is Current in invisible
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_hidden) /= 0
		end

	is_input_grabbed: BOOLEAN assign set_is_input_grabbed
			-- Is Current grabbing all input
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowgrab (item)
		end

	is_maximized: BOOLEAN assign set_is_maximized
			-- Is Current in maximized mode (to fill the screen)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_maximized) /= 0
		end

	is_minimized: BOOLEAN assign set_is_minimized
			-- Is Current in iconized representation
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_minimized) /= 0
		end

	is_opengl_compatible: BOOLEAN
			-- Is Current can be used in an OpenGL context
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_opengl) /= 0
		end

	is_resizable: BOOLEAN
			-- Can Current be resized by the user
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_resizable) /= 0
		end

	is_events_running: BOOLEAN assign set_is_running
			-- Is Current active
			-- (from GAME_EVENTS)

	is_visible: BOOLEAN
			-- Is Current in can be seen in the screen (not hidden)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := {GAME_SDL_EXTERNAL}.sdl_getwindowflags (item).bit_and ({GAME_SDL_EXTERNAL}.sdl_window_shown) /= 0
		end

	key_pressed_actions: ACTION_SEQUENCE [NATURAL_32, GAME_KEY_EVENT]
			-- When a key (represented by key_state) has been pressed.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			key_released_events_enabled: events_controller.is_key_pressed_event_enable
		do
			if attached key_pressed_actions_internal as la_key_pressed_actions_internal then
				Result := la_key_pressed_actions_internal
			else
				create Result
				if is_events_running and not events_controller.key_pressed_actions.has (key_pressed_events_callback) then
					events_controller.key_pressed_actions.extend (key_pressed_events_callback)
				end
				key_pressed_actions_internal := Result
			end
		end

	key_released_actions: ACTION_SEQUENCE [NATURAL_32, GAME_KEY_EVENT]
			-- When a key (represented by key_state) has been released.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			key_released_events_enabled: events_controller.is_key_released_event_enable
		do
			if attached key_released_actions_internal as la_key_released_actions_internal then
				Result := la_key_released_actions_internal
			else
				create Result
				if is_events_running and not events_controller.key_released_actions.has (key_released_events_callback) then
					events_controller.key_released_actions.extend (key_released_events_callback)
				end
				key_released_actions_internal := Result
			end
		end

	keyboard_focus_gain_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has gain keyboard focus.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached keyboard_focus_gain_actions_internal as la_keyboard_focus_gain_actions_internal then
				Result := la_keyboard_focus_gain_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				keyboard_focus_gain_actions_internal := Result
			end
		end

	keyboard_focus_lost_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has lost keyboard focus.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached keyboard_focus_lost_actions_internal as la_keyboard_focus_lost_actions_internal then
				Result := la_keyboard_focus_lost_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				keyboard_focus_lost_actions_internal := Result
			end
		end

	last_error: READABLE_STRING_GENERAL
			-- The last error generate by the library
			-- (from GAME_SDL_ANY)
		local
			l_string: C_STRING
		do
			if is_manual_error then
				Result := Precursor {GAME_ERROR_MANAGER}
			else
				create l_string.make_by_pointer ({GAME_SDL_EXTERNAL}.sdl_geterror)
				Result := l_string.string
			end
		end

	maximize
			-- Change the dimension of Current to fill the screen
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_maximizewindow (item)
		end

	maximize_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has been maximized.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached maximize_actions_internal as la_maximize_actions_internal then
				Result := la_maximize_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				maximize_actions_internal := Result
			end
		end

	maximum_size: TUPLE [width: INTEGER_32; height: INTEGER_32]
			-- The maximum dimension that Current can take
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_width, l_height: INTEGER_32
		do
			{GAME_SDL_EXTERNAL}.sdl_getwindowmaximumsize (item, $l_width.to_pointer, $l_height.to_pointer)
			Result := [l_width, l_height]
		end

	minimize
			-- Put Current in an iconic representation
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_minimizewindow (item)
		end

	minimize_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has been minimized.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached minimize_actions_internal as la_minimize_actions_internal then
				Result := la_minimize_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				minimize_actions_internal := Result
			end
		end

	minimum_size: TUPLE [width: INTEGER_32; height: INTEGER_32]
			-- The minimum dimension that Current can take
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_width, l_height: INTEGER_32
		do
			{GAME_SDL_EXTERNAL}.sdl_getwindowminimumsize (item, $l_width.to_pointer, $l_height.to_pointer)
			Result := [l_width, l_height]
		end

	mouse_button_pressed_actions: ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_BUTTON_PRESS_EVENT, NATURAL_8]
			-- When a mouse represented by mouse_state has been pressed for the nb_clicks times
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			mouse_button_pressed_events_enabled: events_controller.is_mouse_button_pressed_event_enable
		do
			if attached mouse_button_pressed_actions_internal as la_mouse_button_pressed_actions_internal then
				Result := la_mouse_button_pressed_actions_internal
			else
				create Result
				if is_events_running and not events_controller.mouse_button_pressed_actions.has (mouse_button_pressed_events_callback) then
					events_controller.mouse_button_pressed_actions.extend (mouse_button_pressed_events_callback)
				end
				mouse_button_pressed_actions_internal := Result
			end
		end

	mouse_button_released_actions: ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_BUTTON_RELEASE_EVENT, NATURAL_8]
			-- When a mouse represented by mouse_state has been released for the nb_clicks times
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			mouse_button_released_events_enabled: events_controller.is_mouse_button_released_event_enable
		do
			if attached mouse_button_released_actions_internal as la_mouse_button_released_actions_internal then
				Result := la_mouse_button_released_actions_internal
			else
				create Result
				if is_events_running and not events_controller.mouse_button_released_actions.has (mouse_button_released_events_callback) then
					events_controller.mouse_button_released_actions.extend (mouse_button_released_events_callback)
				end
				mouse_button_released_actions_internal := Result
			end
		end

	mouse_enter_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has gained mouse focus.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached mouse_enter_actions_internal as la_mouse_enter_actions_internal then
				Result := la_mouse_enter_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				mouse_enter_actions_internal := Result
			end
		end

	mouse_leave_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has lost mouse focus.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached mouse_leave_actions_internal as la_mouse_leave_actions_internal then
				Result := la_mouse_leave_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				mouse_leave_actions_internal := Result
			end
		end

	mouse_motion_actions: ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_MOTION_EVENT, INTEGER_32, INTEGER_32]
			-- When a mouse represented by mouse_state has been moved in Current.
			-- The difference between the old position and the new (delta_x,delta_y)
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			mouse_motion_events_enabled: events_controller.is_mouse_motion_event_enable
		do
			if attached mouse_motion_actions_internal as la_mouse_motion_actions_internal then
				Result := la_mouse_motion_actions_internal
			else
				create Result
				if is_events_running and not events_controller.mouse_motion_actions.has (mouse_motion_events_callback) then
					events_controller.mouse_motion_actions.extend (mouse_motion_events_callback)
				end
				mouse_motion_actions_internal := Result
			end
		end

	mouse_wheel_move_actions: ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_EVENT, INTEGER_32, INTEGER_32]
			-- When the wheel of a mouse represented by mouse_state has been moved.
			-- The difference between the old wheel position and the new one is (delta_x,delta_y)
			-- When delta_x is positive, the wheel has been move up, and when negative, it has been moved down
			-- When delta_y is positive, the wheel has been move right, and when negative, it has been moved left
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			mouse_wheel_move_events_enabled: events_controller.is_mouse_wheel_event_enable
		do
			if attached mouse_wheel_move_actions_internal as la_mouse_wheel_move_actions_internal then
				Result := la_mouse_wheel_move_actions_internal
			else
				create Result
				if is_events_running and not events_controller.mouse_wheel_move_actions.has (mouse_wheel_move_events_callback) then
					events_controller.mouse_wheel_move_actions.extend (mouse_wheel_move_events_callback)
				end
				mouse_wheel_move_actions_internal := Result
			end
		end

	move_actions: ACTION_SEQUENCE [NATURAL_32, INTEGER_32, INTEGER_32]
			-- When Current has been moved to (x,y).
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached move_actions_internal as la_move_actions_internal then
				Result := la_move_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				move_actions_internal := Result
			end
		end

	move_mouse_to_position (a_x, a_y: INTEGER_32)
			-- Place the mouse at position (a_x,a_y) into Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			windows_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_warpmouseinwindow (item, a_x, a_y)
		end

	pixel_format: GAME_PIXEL_FORMAT_READABLE
			-- The internal format of the pixel representation in memory.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			create Result.make_from_flags ({GAME_SDL_EXTERNAL}.sdl_getwindowpixelformat (item))
		end

	position: TUPLE [x: INTEGER_32; y: INTEGER_32]
			-- The coordinate (x,y) of the position of Current in the screen.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_x, l_y: INTEGER_32
		do
			{GAME_SDL_EXTERNAL}.sdl_getwindowposition (item, $l_x.to_pointer, $l_y.to_pointer)
			Result := [l_x, l_y]
		end

	put_border
			-- Put border decoration to Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowbordered (item, True)
		end

	raise
			-- Put Current to the front
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_raisewindow (item)
		end

	release_input
			-- Release the input previously forced into Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowgrab (item, False)
		ensure -- from GAME_WINDOW
			is_not_grabbed: not is_input_grabbed
		end

	remove_border
			-- Remove border decoration to Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowbordered (item, False)
		end

	resize_actions: ACTION_SEQUENCE [NATURAL_32, INTEGER_32, INTEGER_32]
			-- When Current has been resized by the user (external to the game library)
			-- to widthxheight. Always precceded by a size_change_actions events.
			-- Note: This event is not trigger by the GAME_WINDOW.set_size or GAME_WINDOW.set_full_screen
			-- Routines
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached resize_actions_internal as la_resize_actions_internal then
				Result := la_resize_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				resize_actions_internal := Result
			end
		end

	restore
			-- Get the original dimension of Current (previously change with maximize or minimize)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_restorewindow (item)
		end

	restore_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has been restored to normal size and position.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached restore_actions_internal as la_restore_actions_internal then
				Result := la_restore_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				restore_actions_internal := Result
			end
		end

	run_events
			-- Put Current active.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_EVENTS
			run_not_already_running: not is_events_running
		do
			is_events_running := True
			if attached show_actions_internal or attached hide_actions_internal or attached expose_actions_internal or attached move_actions_internal or attached resize_actions_internal or attached size_change_actions_internal or attached minimize_actions_internal or attached maximize_actions_internal or attached restore_actions_internal or attached mouse_enter_actions_internal or attached mouse_leave_actions_internal or attached keyboard_focus_gain_actions_internal or attached keyboard_focus_lost_actions_internal or attached close_request_actions_internal then
				events_controller.window_event_actions.extend (window_events_callback)
			end
			if attached key_pressed_actions_internal then
				events_controller.key_pressed_actions.extend (key_pressed_events_callback)
			end
			if attached key_released_actions_internal then
				events_controller.key_released_actions.extend (key_released_events_callback)
			end
			if attached text_editing_actions_internal then
				events_controller.text_editing_actions.extend (text_editing_events_callback)
			end
			if attached text_input_actions_internal then
				events_controller.text_input_actions.extend (text_input_events_callback)
			end
			if attached mouse_motion_actions_internal then
				events_controller.mouse_motion_actions.extend (mouse_motion_events_callback)
			end
			if attached mouse_button_pressed_actions_internal then
				events_controller.mouse_button_pressed_actions.extend (mouse_button_pressed_events_callback)
			end
			if attached mouse_button_released_actions_internal then
				events_controller.mouse_button_released_actions.extend (mouse_button_released_events_callback)
			end
			if attached mouse_wheel_move_actions_internal then
				events_controller.mouse_wheel_move_actions.extend (mouse_wheel_move_events_callback)
			end
		ensure -- from GAME_EVENTS
			is_running: is_events_running
		end

	set_brightness (a_brightness: REAL_32)
			-- Set the brightness (gamma correction) to a_brightness for Current where 0.0 is completely dark and 1.0 is normal.
			-- Set has_error when an error occured.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
			window_set_brightness_valid: a_brightness >= 0.0 and a_brightness <= 1.to_real
		local
			l_error: INTEGER_32
		do
			clear_error
			has_error := False
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowbrightness (item, a_brightness)
			manage_error_code (l_error, "An error occured when setting the brightness of the window.")
		ensure -- from GAME_WINDOW
			window_set_brightness_changed: brightness = a_brightness
		end

	set_clipboard_text (a_text: READABLE_STRING_GENERAL)
			-- Put a_text into the system clipboard
			-- (from GAME_WINDOW)
		local
			l_converter: UTF_CONVERTER
			l_error: INTEGER_32
			l_c_string: C_STRING
		do
			clear_error
			create l_c_string.make (l_converter.string_32_to_utf_8_string_8 (a_text.to_string_32))
			l_error := {GAME_SDL_EXTERNAL}.sdl_setclipboardtext (l_c_string.item)
			manage_error_code (l_error, "Cannot put text into the system clipboard.")
		end

	set_display_mode (a_display_mode: GAME_DISPLAY_MODE)
			-- Assign display_mode with the value of a_display_mode
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_error: INTEGER_32
		do
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowdisplaymode (item, a_display_mode.item)
			manage_error_code (l_error, "Cannot assign a display mode to a window.")
		end

	set_fake_fullscreen
			-- Activate the "fake" fullscreen mode (setting a not bordered maximized window)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_error: INTEGER_32
		do
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowfullscreen (item, {GAME_SDL_EXTERNAL}.sdl_window_fullscreen_desktop)
			manage_error_code (l_error, "Cannot set window to full screen (fake)")
		end

	set_fullscreen
			-- Activate the "true" fullscreen mode (changing resolution if necessary)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_error: INTEGER_32
		do
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowfullscreen (item, {GAME_SDL_EXTERNAL}.sdl_window_fullscreen)
			manage_error_code (l_error, "Cannot set window to full screen (true)")
		end

	set_gamma_correction (a_red, a_green, a_blue: ARRAYED_LIST [NATURAL_16])
			-- Assign the gamma_correction values using a_red, a_green, a_blue.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
			red_arrays_count_valid: a_red.count = 256
			green_arrays_count_valid: a_green.count = 256
			blue_arrays_count_valid: a_blue.count = 256
		local
			l_red, l_green, l_blue: ARRAY [NATURAL_16]
			l_error: INTEGER_32
		do
			l_red := a_red.to_array
			l_green := a_green.to_array
			l_blue := a_blue.to_array
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowgammaramp (item, $l_red.to_pointer, $l_green.to_pointer, $l_blue.to_pointer)
			manage_error_code (l_error, "Cannot set gamma correction values.")
		ensure -- from GAME_WINDOW
			is_assign: attached gamma_correction as la_gamma_correction and then (la_gamma_correction.red ~ a_red and la_gamma_correction.green ~ a_green and la_gamma_correction.blue ~ a_blue)
		end

	set_height (a_height: INTEGER_32)
			-- Assign height with the value of a_height
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_size (width, a_height)
		ensure -- from GAME_WINDOW
			is_assign: height = a_height
			width_not_changed: width = old width
		end

	set_icon (a_surface: GAME_SURFACE)
			-- Place the icon represented by a_surface as Current icon (in the decoration)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			windows_not_closed: exists
			surface_exists: a_surface.is_open
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowicon (item, a_surface.item)
		end

	set_is_fake_fullscreen (a_value: BOOLEAN)
			-- Assign to is_fake_fullscreen the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				set_fake_fullscreen
			else
				set_windowed
			end
		ensure -- from GAME_WINDOW
			is_assign: is_fake_fullscreen ~ a_value
		end

	set_is_fullscreen (a_value: BOOLEAN)
			-- Assign to is_fullscreen the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				set_fullscreen
			else
				set_windowed
			end
		ensure -- from GAME_WINDOW
			is_assign: is_fullscreen ~ a_value
		end

	set_is_hidden (a_value: BOOLEAN)
			-- Assign to is_hidden the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				hide
			else
				show
			end
		ensure -- from GAME_WINDOW
			is_assign: is_hidden ~ a_value
		end

	set_is_input_grabbed (a_value: BOOLEAN)
			-- Assign to is_input_grabbed the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				grab_input
			else
				release_input
			end
		ensure -- from GAME_WINDOW
			is_assign: is_input_grabbed ~ a_value
		end

	set_is_maximized (a_value: BOOLEAN)
			-- Assign to is_maximized the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				maximize
			else
				restore
			end
		ensure -- from GAME_WINDOW
			is_assign: is_maximized ~ a_value
		end

	set_is_minimized (a_value: BOOLEAN)
			-- Assign to is_minimized the value of a_value
			-- (from GAME_WINDOW)
		do
			if a_value then
				minimize
			else
				restore
			end
		ensure -- from GAME_WINDOW
			is_assign: is_minimized ~ a_value
		end

	set_is_running (a_value: BOOLEAN)
			-- Assign to is_running the value of a_value
			-- (from GAME_EVENTS)
		do
			if a_value then
				run_events
			else
				stop_events
			end
		ensure -- from GAME_EVENTS
			is_assign: is_events_running ~ a_value
		end

	set_maximum_size (a_width, a_height: INTEGER_32)
			-- Assign the values of maximum_size with the values a_width, a_height
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowmaximumsize (item, a_width, a_height)
		end

	set_minimum_size (a_width, a_height: INTEGER_32)
			-- Assign the values of minimum_size with the values a_width, a_height
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowminimumsize (item, a_width, a_height)
		end

	set_position (a_x, a_y: INTEGER_32)
			-- Assign position with the values a_x and a_y
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowposition (item, a_x, a_y)
		end

	set_size (a_width, a_height: INTEGER_32)
			-- Assign the values of size with the values a_width, a_height
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			{GAME_SDL_EXTERNAL}.sdl_setwindowsize (item, a_width, a_height)
		ensure -- from GAME_WINDOW
			is_assign: attached size as la_size and then (la_size.width ~ a_width and la_size.height ~ a_height)
		end

	set_title (a_title: READABLE_STRING_GENERAL)
			-- Assign title using the value of a_title
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_utf_converter: UTF_CONVERTER
			l_text_m_ptr: MANAGED_POINTER
			l_count: INTEGER_32
		do
			create l_utf_converter
			l_count := l_utf_converter.utf_8_bytes_count (a_title, 1, a_title.count) + 1
			create l_text_m_ptr.make (l_count);
			l_utf_converter.string_32_into_utf_8_0_pointer (a_title.as_string_32, l_text_m_ptr, 0, Void)
			check
				pointer_not_null: not l_text_m_ptr.item.is_default_pointer
			end
			{GAME_SDL_EXTERNAL}.sdl_setwindowtitle (item, l_text_m_ptr.item)
		end

	set_width (a_width: INTEGER_32)
			-- Assign width with the value of a_width
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_size (a_width, height)
		ensure -- from GAME_WINDOW
			is_assign: width = a_width
			height_not_changed: height = old height
		end

	set_windowed
			-- Desactivate any fullscreen mode
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_error: INTEGER_32
		do
			l_error := {GAME_SDL_EXTERNAL}.sdl_setwindowfullscreen (item, 0)
			manage_error_code (l_error, "Cannot set window to not fullscreen")
		end

	set_x (a_x: INTEGER_32)
			-- assign x with the value of a_x
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_position (a_x, y)
		ensure -- from GAME_WINDOW
			is_assign: x = a_x
		end

	set_y (a_y: INTEGER_32)
			-- assign y with the value of a_y
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			set_position (x, a_y)
		ensure -- from GAME_WINDOW
			is_assign: y = a_y
		end

	show
			-- Active the visibility of Current (previously removed by hide)
			-- (from GAME_WINDOW)
		do
			{GAME_SDL_EXTERNAL}.sdl_showwindow (item)
		end

	show_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current is show.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached show_actions_internal as la_show_actions_internal then
				Result := la_show_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				show_actions_internal := Result
			end
		end

	size: TUPLE [width: INTEGER_32; height: INTEGER_32]
			-- The present dimension of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_width, l_height: INTEGER_32
		do
			{GAME_SDL_EXTERNAL}.sdl_getwindowsize (item, $l_width.to_pointer, $l_height.to_pointer)
			Result := [l_width, l_height]
		end

	size_change_actions: ACTION_SEQUENCE [NATURAL_32]
			-- When Current has been resized.
			-- Note: Trigger when a user resize the window (external to the game library) or when a
			-- call to the GAME_WINDOW.set_size or GAME_WINDOW.set_full_screen routines has
			-- been use.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_WINDOW_EVENTS
			window_events_enabled: events_controller.is_window_event_enable
		do
			if attached size_change_actions_internal as la_size_change_actions_internal then
				Result := la_size_change_actions_internal
			else
				create Result
				if is_events_running and not events_controller.window_event_actions.has (window_events_callback) then
					events_controller.window_event_actions.extend (window_events_callback)
				end
				size_change_actions_internal := Result
			end
		end

	start_text_input
			-- Begin to read text in Current
			-- (from GAME_WINDOW)
		do
			{GAME_SDL_EXTERNAL}.sdl_starttextinput
		end

	start_text_input_in_rectangle (a_x, a_y, a_width, a_height: INTEGER_32)
			-- Begin to read text in Current displaying updated in the
			-- rectangle starting at position (a_x, a_y) of dimention a_width X a_height.
			-- Note: The library will not automatically draw the text in the rectangle.
			-- The coordinate and dimention will be use to show the OS candidate list (if there is one).
			-- See: http://wiki.libsdl.org/Tutorials/TextInput#CandidateList
			-- (from GAME_WINDOW)
		local
			l_rectangle: POINTER
		do
			l_rectangle := l_rectangle.memory_calloc (1, {GAME_SDL_EXTERNAL}.c_sizeof_sdl_rect)
			{GAME_SDL_EXTERNAL}.set_rect_struct_x (l_rectangle, a_x)
			{GAME_SDL_EXTERNAL}.set_rect_struct_y (l_rectangle, a_y)
			{GAME_SDL_EXTERNAL}.set_rect_struct_w (l_rectangle, a_width)
			{GAME_SDL_EXTERNAL}.set_rect_struct_h (l_rectangle, a_height)
			{GAME_SDL_EXTERNAL}.sdl_settextinputrect (l_rectangle)
			start_text_input;
			l_rectangle.memory_free
		end

	stop_events
			-- Put Current innactive.
			-- (from GAME_WINDOW_EVENTS)
		require -- from GAME_EVENTS
			stop_is_running: is_events_running
		do
			is_events_running := False;
			events_controller.window_event_actions.prune_all (window_events_callback);
			events_controller.key_pressed_actions.prune_all (key_pressed_events_callback);
			events_controller.text_editing_actions.prune_all (text_editing_events_callback);
			events_controller.text_input_actions.prune_all (text_input_events_callback);
			events_controller.mouse_motion_actions.prune_all (mouse_motion_events_callback);
			events_controller.mouse_button_pressed_actions.prune_all (mouse_button_pressed_events_callback);
			events_controller.mouse_button_released_actions.prune_all (mouse_button_released_events_callback);
			events_controller.mouse_wheel_move_actions.prune_all (mouse_wheel_move_events_callback)
		ensure -- from GAME_EVENTS
			is_stopped: not is_events_running
		end

	stop_text_input
			-- Finish the reading of text in Current
			-- (from GAME_WINDOW)
		do
			{GAME_SDL_EXTERNAL}.sdl_stoptextinput
		end

	text_editing_actions: ACTION_SEQUENCE [NATURAL_32, STRING_32, INTEGER_32, INTEGER_32]
			-- When a text has been edited in Current.
			-- (from GAME_WINDOW_EVENTS)
		do
			if attached text_editing_actions_internal as la_text_editing_actions_internal then
				Result := la_text_editing_actions_internal
			else
				create Result
				if is_events_running and not events_controller.text_editing_actions.has (text_editing_events_callback) then
					events_controller.text_editing_actions.extend (text_editing_events_callback)
				end
				text_editing_actions_internal := Result
			end
		end

	text_input_actions: ACTION_SEQUENCE [NATURAL_32, STRING_32]
			-- When a new text has been entered in Current.
			-- (from GAME_WINDOW_EVENTS)
		do
			if attached text_input_actions_internal as la_text_input_actions_internal then
				Result := la_text_input_actions_internal
			else
				create Result
				if is_events_running and not events_controller.text_input_actions.has (text_input_events_callback) then
					events_controller.text_input_actions.extend (text_input_events_callback)
				end
				text_input_actions_internal := Result
			end
		end

	title: READABLE_STRING_GENERAL assign set_title
			-- The text to write in the title bar of Current (part of the decoration)
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_text_c: C_STRING
		do
			create l_text_c.make_by_pointer ({GAME_SDL_EXTERNAL}.sdl_getwindowtitle (item))
			Result := {UTF_CONVERTER}.utf_8_string_8_to_string_32 (l_text_c.string)
		end

	update
			-- Print the visual buffer modification to the screen
		require -- from GAME_WINDOW
			window_not_closed: exists
		require else
				gl_context_valid
		do
			{GAME_SDL_EXTERNAL}.sdl_gl_swapwindow (item)
		end

	width: INTEGER_32 assign set_width
			-- The horizontal length of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := size.width
		end

	window_manager: GAME_WINDOW_MANAGER
			-- The window manager managing Current.
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		local
			l_wm_info: POINTER
			l_valid: BOOLEAN
		do
			l_wm_info := l_wm_info.memory_calloc (1, {GAME_SDL_EXTERNAL}.c_sizeof_sdl_sys_wm_info)
			{GAME_SDL_EXTERNAL}.sdl_version_compile ({GAME_SDL_EXTERNAL}.get_sys_wm_struct_version (l_wm_info))
			clear_error
			l_valid := {GAME_SDL_EXTERNAL}.sdl_getwindowwminfo (item, l_wm_info)
			manage_error_boolean (l_valid, "An error occured when getting the window manager informations.")
			create Result.own_from_pointer (l_wm_info)
		end

	x: INTEGER_32 assign set_x
			-- The horizontal coordinate of the position of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := position.x
		end

	y: INTEGER_32 assign set_y
			-- The vertical coordinate of the position of Current
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			window_not_closed: exists
		do
			Result := position.x
		end
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_deep_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)
		end

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))
		end

	frozen is_deep_equal alias "≡≡≡" (other: GAME_WINDOW_GL): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)
		end

	is_equal (other: GAME_WINDOW_GL): BOOLEAN
			-- Is other attached to an object considered
			-- equal to current object?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			symmetric: Result implies other ~ Current
			consistent: standard_is_equal (other) implies Result
		end

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.standard_is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))
		end

	frozen standard_is_equal alias "≜" (other: GAME_WINDOW_GL): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
		end
	
feature -- Status report

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		end

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
		end
	
feature {NONE} -- Status report

	is_in_final_collect: BOOLEAN
			-- Is GC currently performing final collection
			-- after execution of current program?
			-- Safe to use in dispose.
			-- (from DISPOSABLE)
		external
			"C inline use %"eif_memory.h%""
		alias
			"return eif_is_in_final_collect;"
		end
	
feature -- Duplication

	frozen clone (other: detachable ANY): like other
		obsolete "Use `twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- equal to other
			--
			-- For non-void other, clone calls copy;
			-- to change copying/cloning semantics, redefine copy.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.twin
			end
		ensure -- from ANY
			instance_free: class
			equal: Result ~ other
		end

	copy (other: GAME_WINDOW_GL)
			-- Update current object using fields of object attached
			-- to other, so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_equal: Current ~ other
		end

	frozen deep_clone (other: detachable ANY): like other
		obsolete "Use `deep_twin' instead. [2017-05-31]"
			-- Void if other is void: otherwise, new object structure
			-- recursively duplicated from the one attached to other
			-- (from ANY)
		do
			if other /= Void then
				Result := other.deep_twin
			end
		ensure -- from ANY
			instance_free: class
			deep_equal: deep_equal (other, Result)
		end

	frozen deep_copy (other: GAME_WINDOW_GL)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		do
			copy (other.deep_twin)
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)
		end

	frozen deep_twin: GAME_WINDOW_GL
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)
		end

	frozen standard_clone (other: detachable ANY): like other
		obsolete "Use `standard_twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.standard_twin
			end
		ensure -- from ANY
			instance_free: class
			equal: standard_equal (Result, other)
		end

	frozen standard_copy (other: GAME_WINDOW_GL)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)
		end

	frozen standard_twin: GAME_WINDOW_GL
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)
		end

	frozen twin: GAME_WINDOW_GL
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
		end
	
feature -- Basic operations

	frozen as_attached: attached GAME_WINDOW_GL
		obsolete "Remove calls to this feature. [2017-05-31]"
			-- Attached version of Current.
			-- (Can be used during transitional period to convert
			-- non-void-safe classes to void-safe ones.)
			-- (from ANY)
		do
			Result := Current
		end

	frozen default: detachable GAME_WINDOW_GL
			-- Default value of object's type
			-- (from ANY)
		do
		end

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end
	
feature {NONE} -- Implementation

	clear_error
			-- Remove error pending in Current
			-- (from GAME_SDL_ANY)
		require -- from  GAME_ERROR_MANAGER
			True
		do
			{GAME_SDL_EXTERNAL}.sdl_clearerror
			Precursor {GAME_ERROR_MANAGER}
			is_manual_error := False
		ensure -- from GAME_ERROR_MANAGER
			no_error: not has_error
		ensure then -- from GAME_SDL_ANY
			no_error: not is_manual_error
		end

	close_request_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the close_request_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	disable_print_on_error
			-- Desactive the print_on_error functionnality.
			-- (from GAME_ERROR_MANAGER)
		do
			Print_on_error_internal.put (False)
		end

	enable_print_on_error
			-- Active the print_on_error functionnality.
			-- (from GAME_ERROR_MANAGER)
		do
			Print_on_error_internal.put (True)
		end

	expose_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the expose_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	gl_context: POINTER
			-- The GL context associate with the window

	gl_context_flags: INTEGER_32
			-- The context internal flags
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_context_flags, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL context information")
			Result := l_value
		end

	gl_context_profile_flags: INTEGER_32
			-- The context profile flags
		require
				gl_context_valid
		local
			l_error, l_value: INTEGER_32
		do
			clear_error
			l_error := {GAME_SDL_EXTERNAL}.sdl_gl_getattribute ({GAME_SDL_EXTERNAL}.sdl_gl_context_profile_mask, $l_value.to_pointer)
			manage_error_code (l_error, "Could not get the OpenGL context profile information")
			Result := l_value
		end

	hide_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the hide_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	internal_game_library: detachable GAME_LIBRARY_CONTROLLER
			-- Assign to this attribute prior to use Game_library to inject a specific GAME_LIBRARY_CONTROLLER singleton.
			-- (from GAME_LIBRARY_SHARED)

	is_manual_error: BOOLEAN
			-- Is the current pending error is a manual error (using manual_error as message)
			-- (from GAME_SDL_ANY)

	key_pressed_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_KEY_EVENT]
			-- Internal value of the key_pressed_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	key_pressed_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_8, INTEGER_32, INTEGER_32, NATURAL_16]
			-- Callback used to register Current in the events_controller for the
			-- key_pressed_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	key_pressed_events_dispatcher (a_timestamp, a_window_id: NATURAL_32; a_repeat: NATURAL_8; a_scancode, a_keycode: INTEGER_32; a_modifier: NATURAL_16)
			-- The dispatcher receiving event from the key_pressed_events_callback and dispatch them to
			-- the key_pressed_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		local
			l_keyboard_state: GAME_KEY_EVENT
		do
			if (a_window_id = id or a_window_id = 0) and then attached key_pressed_actions_internal as actions then
				create l_keyboard_state.make (a_scancode, a_keycode, a_modifier, a_repeat);
				actions.call (a_timestamp, l_keyboard_state)
			end
		end

	key_released_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_KEY_EVENT]
			-- Internal value of the key_released_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	key_released_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_8, INTEGER_32, INTEGER_32, NATURAL_16]
			-- Callback used to register Current in the events_controller for the
			-- key_released_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	key_released_events_dispatcher (a_timestamp, a_window_id: NATURAL_32; a_repeat: NATURAL_8; a_scancode, a_keycode: INTEGER_32; a_modifier: NATURAL_16)
			-- The dispatcher receiving event from the key_released_events_callback and dispatch them to
			-- the key_released_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		local
			l_keyboard_state: GAME_KEY_EVENT
		do
			if (a_window_id = id or a_window_id = 0) and then attached key_released_actions_internal as actions then
				create l_keyboard_state.make (a_scancode, a_keycode, a_modifier, a_repeat);
				actions.call (a_timestamp, l_keyboard_state)
			end
		end

	keyboard_focus_gain_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the keyboard_focus_gain_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	keyboard_focus_lost_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the keyboard_focus_lost_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	manage_error_boolean (a_boolean: BOOLEAN; a_message: READABLE_STRING_GENERAL)
			-- Create an error if a_boolean is false.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if not a_boolean then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		ensure -- from GAME_SDL_ANY
				not a_boolean implies has_error
		end

	manage_error_code (a_error_code: INTEGER_32; a_message: READABLE_STRING_GENERAL)
			-- If needed create an error depending of the error code a_code.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if a_error_code < 0 then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		end

	manage_error_pointer (a_pointer: POINTER; a_message: READABLE_STRING_GENERAL)
			-- Create an error if a_pointer is not valid.
			-- If there is an error, append a_message to the error message
			-- on the SDL2 library
			-- (from GAME_SDL_ANY)
		do
			if a_pointer.is_default_pointer then
				if Print_on_error_internal.item then
					Io.Error.put_string (a_message.to_string_8 + "%N");
					Io.Error.put_string (last_error.to_string_8 + "%N")
				end
				has_error := True
			end
		ensure -- from GAME_SDL_ANY
				a_pointer.is_default_pointer implies has_error
		end

	maximize_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the maximize_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	manual_error: detachable READABLE_STRING_GENERAL
			-- The specific message for the last error
			-- (from GAME_ERROR_MANAGER)

	minimize_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the minimize_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_button_pressed_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_BUTTON_PRESS_EVENT, NATURAL_8]
			-- Internal value of the mouse_button_pressed_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_button_pressed_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_32, NATURAL_8, NATURAL_8, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for the
			-- mouse_button_pressed_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	mouse_button_pressed_events_dispatcher (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_button, a_clicks: NATURAL_8; a_x, a_y: INTEGER_32)
			-- The dispatcher receiving event from the mouse_button_pressed_events_callback and dispatch them to
			-- the mouse_button_pressed_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		local
			l_mouse_state: GAME_MOUSE_BUTTON_PRESS_EVENT
		do
			if (a_window_id = id or a_window_id = 0) and then attached mouse_button_pressed_actions_internal as actions then
				create l_mouse_state.make (a_mouse_id, a_button.to_natural_32, a_x, a_y);
				actions.call (a_timestamp, l_mouse_state, a_clicks)
			end
		end

	mouse_button_released_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_BUTTON_RELEASE_EVENT, NATURAL_8]
			-- Internal value of the mouse_button_released_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_button_released_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_32, NATURAL_8, NATURAL_8, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for the
			-- mouse_button_released_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	mouse_button_released_events_dispatcher (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_button, a_clicks: NATURAL_8; a_x, a_y: INTEGER_32)
			-- The dispatcher receiving event from the mouse_button_released_events_callback and dispatch them to
			-- the mouse_button_released_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		local
			l_mouse_state: GAME_MOUSE_BUTTON_RELEASE_EVENT
		do
			if (a_window_id = id or a_window_id = 0) and then attached mouse_button_released_actions_internal as actions then
				create l_mouse_state.make (a_mouse_id, a_button.to_natural_32, a_x, a_y);
				actions.call (a_timestamp, l_mouse_state, a_clicks)
			end
		end

	mouse_enter_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the mouse_enter_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_leave_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the mouse_leave_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_motion_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_MOTION_EVENT, INTEGER_32, INTEGER_32]
			-- Internal value of the mouse_motion_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_motion_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_32, NATURAL_32, INTEGER_32, INTEGER_32, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for the
			-- mouse_motion_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	mouse_motion_events_dispatcher (a_timestamp, a_window_id, a_mouse_id, a_state: NATURAL_32; a_x, a_y, a_x_relative, a_y_relative: INTEGER_32)
			-- The dispatcher receiving event from the mouse_motion_events_callback and dispatch them to
			-- the mouse_motion_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		local
			l_mouse_state: GAME_MOUSE_MOTION_EVENT
		do
			if (a_window_id = id or a_window_id = 0) and then attached mouse_motion_actions_internal as actions then
				create l_mouse_state.make (a_mouse_id, a_state, a_x, a_y);
				actions.call (a_timestamp, l_mouse_state, a_x_relative, a_y_relative)
			end
		end

	mouse_wheel_move_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, GAME_MOUSE_EVENT, INTEGER_32, INTEGER_32]
			-- Internal value of the mouse_wheel_move_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	mouse_wheel_move_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_32, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for the
			-- mouse_wheel_move_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	mouse_wheel_move_events_dispatcher (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_x, a_y: INTEGER_32)
			-- The dispatcher receiving event from the mouse_wheel_move_events_callback and dispatch them to
			-- the mouse_wheel_move_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		do
			if (a_window_id = id or a_window_id = 0) and then attached mouse_wheel_move_actions_internal as actions then
				actions.call (a_timestamp, create {GAME_MOUSE_EVENT}.make (a_mouse_id), a_x, a_y)
			end
		end

	move_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, INTEGER_32, INTEGER_32]
			-- Internal value of the move_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	print_on_error: BOOLEAN
			-- When an error occured, the library will print
			-- informations about the error on the error console
			-- output (default is True).
			-- (from GAME_ERROR_MANAGER)
		do
			Result := Print_on_error_internal.item
		end

	Print_on_error_internal: CELL [BOOLEAN]
			-- True when an error occured,
			-- The library will print it right away.
			-- (from GAME_ERROR_MANAGER)
		once ("PROCESS")
			create Result.put (True)
		end

	put_manual_error (a_general_message, a_specific_error: READABLE_STRING_GENERAL)
			-- Create an error using a_general_error for the debug information
			-- and a_specific_error for the lasting information
			-- (from GAME_SDL_ANY)
		do
			is_manual_error := True
			Precursor {GAME_ERROR_MANAGER} (a_general_message, a_specific_error)
		ensure -- from GAME_ERROR_MANAGER
				has_error
		end

	resize_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, INTEGER_32, INTEGER_32]
			-- Internal value of the resize_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	restore_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the restore_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	set_print_on_error (a_value: BOOLEAN)
			-- Assign to print_on_error the value of a_value
			-- (from GAME_ERROR_MANAGER)
		do
			if a_value then
				enable_print_on_error
			else
				disable_print_on_error
			end
		ensure -- from GAME_ERROR_MANAGER
			is_assign: print_on_error ~ a_value
		end

	show_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the show_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	size_change_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32]
			-- Internal value of the size_change_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	text_editing_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, STRING_32, INTEGER_32, INTEGER_32]
			-- Internal value of the text_editing_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	text_editing_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, STRING_32, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for the
			-- text_editing_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	text_editing_events_dispatcher (a_timestamp, a_window_id: NATURAL_32; a_text: STRING_32; a_start, a_lenght: INTEGER_32)
			-- The dispatcher receiving event from the text_editing_events_callback and dispatch them to
			-- the text_editing_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		do
			if (a_window_id = id or a_window_id = 0) and then attached text_editing_actions_internal as actions then
				actions.call (a_timestamp, a_text, a_start, a_lenght)
			end
		end

	text_input_actions_internal: detachable ACTION_SEQUENCE [NATURAL_32, STRING_32]
			-- Internal value of the text_input_actions lazy evaluated attribute
			-- (from GAME_WINDOW_EVENTS)

	text_input_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, STRING_32]
			-- Callback used to register Current in the events_controller for the
			-- text_input_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)

	text_input_events_dispatcher (a_timestamp, a_window_id: NATURAL_32; a_text: STRING_32)
			-- The dispatcher receiving event from the text_input_events_callback and dispatch them to
			-- the text_input_actions ACTION_SEQUENCE
			-- (from GAME_WINDOW_EVENTS)
		do
			if (a_window_id = id or a_window_id = 0) and then attached text_input_actions_internal as actions then
				actions.call (a_timestamp, a_text)
			end
		end

	window_events_callback: PROCEDURE [NATURAL_32, NATURAL_32, NATURAL_8, INTEGER_32, INTEGER_32]
			-- Callback used to register Current in the events_controller for those ACTION_SEQUENCE:
			-- show_actions, expose_actions, hide_actions, move_actions, resize_actions,
			-- size_change_actions, minimize_actions, maximize_actions, restore_actions,
			-- mouse_enter_actions, mouse_leave_actions, keyboard_focus_gain_actions,
			-- keyboard_focus_lost_actions and close_request_actions
			-- (from GAME_WINDOW_EVENTS)

	window_events_dispatcher (a_timestamp, a_window_id: NATURAL_32; a_event_type: NATURAL_8; a_data1, a_data2: INTEGER_32)
			-- The dispatcher receiving event from the window_events_callback and dispatch them to those
			-- ACTION_SEQUENCE: show_actions, expose_actions, hide_actions, move_actions,
			-- resize_actions, size_change_actions, minimize_actions, maximize_actions,
			-- restore_actions, mouse_enter_actions, mouse_leave_actions,
			-- keyboard_focus_gain_actions, keyboard_focus_lost_actions and close_request_actions
			-- (from GAME_WINDOW_EVENTS)
		do
			if a_window_id = id or a_window_id = 0 then
				if a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_shown then
					if attached show_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_hidden then
					if attached hide_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_exposed then
					if attached expose_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_moved then
					if attached move_actions_internal as actions then
						actions.call ([a_timestamp, a_data1, a_data2])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_resized then
					if attached resize_actions_internal as actions then
						actions.call ([a_timestamp, a_data1, a_data2])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_size_changed then
					if attached size_change_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_minimized then
					if attached minimize_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_maximized then
					if attached maximize_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_restored then
					if attached restore_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_enter then
					if attached mouse_enter_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_leave then
					if attached mouse_leave_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_focus_gained then
					if attached keyboard_focus_gain_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_focus_lost then
					if attached keyboard_focus_lost_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				elseif a_event_type = {GAME_SDL_EXTERNAL}.sdl_windowevent_close then
					if attached close_request_actions_internal as actions then
						actions.call ([a_timestamp])
					end
				end
			end
		end
	
feature -- Implementation

	dispose
			-- Close
		require -- from  DISPOSABLE
			True
		do
			if not gl_context.is_default_pointer then
				{GAME_SDL_EXTERNAL}.sdl_gl_deletecontext (gl_context)
			end
		end
	
feature {GAME_RENDERER} 

	item: POINTER
			-- The internal C pointer to the internal representation of Current
			-- (from GAME_WINDOW)
	
feature {NONE} -- Initialisation

	make_events
			-- Initialization of Current
			-- (from GAME_WINDOW_EVENTS)
		do
			window_events_callback := agent (a_timestamp, a_window_id: NATURAL_32; a_event_type: NATURAL_8; a_data1, a_data2: INTEGER_32)
				do
					window_events_dispatcher (a_timestamp, a_window_id, a_event_type, a_data1, a_data2)
				end
			key_pressed_events_callback := agent (a_timestamp, a_window_id: NATURAL_32; a_repeat: NATURAL_8; a_scancode, a_keycode: INTEGER_32; a_modifier: NATURAL_16)
				do
					key_pressed_events_dispatcher (a_timestamp, a_window_id, a_repeat, a_scancode, a_keycode, a_modifier)
				end
			key_released_events_callback := agent (a_timestamp, a_window_id: NATURAL_32; a_repeat: NATURAL_8; a_scancode, a_keycode: INTEGER_32; a_modifier: NATURAL_16)
				do
					key_released_events_dispatcher (a_timestamp, a_window_id, a_repeat, a_scancode, a_keycode, a_modifier)
				end
			text_editing_events_callback := agent (a_timestamp, a_window_id: NATURAL_32; a_text: STRING_32; a_start, a_lenght: INTEGER_32)
				do
					text_editing_events_dispatcher (a_timestamp, a_window_id, a_text, a_start, a_lenght)
				end
			text_input_events_callback := agent (a_timestamp, a_window_id: NATURAL_32; a_text: STRING_32)
				do
					text_input_events_dispatcher (a_timestamp, a_window_id, a_text)
				end
			mouse_motion_events_callback := agent (a_timestamp, a_window_id, a_mouse_id, a_state: NATURAL_32; a_x, a_y, a_x_relative, a_y_relative: INTEGER_32)
				do
					mouse_motion_events_dispatcher (a_timestamp, a_window_id, a_mouse_id, a_state, a_x, a_y, a_x_relative, a_y_relative)
				end
			mouse_button_pressed_events_callback := agent (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_button, a_clicks: NATURAL_8; a_x, a_y: INTEGER_32)
				do
					mouse_button_pressed_events_dispatcher (a_timestamp, a_window_id, a_mouse_id, a_button, a_clicks, a_x, a_y)
				end
			mouse_button_released_events_callback := agent (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_button, a_clicks: NATURAL_8; a_x, a_y: INTEGER_32)
				do
					mouse_button_released_events_dispatcher (a_timestamp, a_window_id, a_mouse_id, a_button, a_clicks, a_x, a_y)
				end
			mouse_wheel_move_events_callback := agent (a_timestamp, a_window_id, a_mouse_id: NATURAL_32; a_x, a_y: INTEGER_32)
				do
					mouse_wheel_move_events_dispatcher (a_timestamp, a_window_id, a_mouse_id, a_x, a_y)
				end
			Precursor {GAME_EVENTS}
		ensure -- from GAME_EVENTS
			make_event_is_running: is_events_running
		end

	position_coordinate_or_flags (a_coordinate: INTEGER_32; a_is_centered, a_is_undefined: BOOLEAN; a_display: detachable GAME_DISPLAY): INTEGER_32
			-- If a_is_centered or a_is_undefined is set, return the corresponding
			-- position flags (managing also a_display if not Void). If they are
			-- both False, return a_coordinate
			-- (from GAME_WINDOW)
		require -- from GAME_WINDOW
			centered_or_undefine: a_is_centered implies not a_is_undefined
		do
			if a_is_centered then
				if attached a_display then
					Result := {GAME_SDL_EXTERNAL}.sdl_windowpos_centered_display (a_display.index)
				else
					Result := {GAME_SDL_EXTERNAL}.sdl_windowpos_centered
				end
			elseif a_is_undefined then
				if attached a_display then
					Result := {GAME_SDL_EXTERNAL}.sdl_windowpos_undefined_display (a_display.index)
				else
					Result := {GAME_SDL_EXTERNAL}.sdl_windowpos_undefined
				end
			else
				Result := a_coordinate
			end
		end
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		once
			create Result;
			Result.set_output_default
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void
		end

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		do
			Result := tagged_out
		ensure -- from ANY
			out_not_void: Result /= Void
		end

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		local
			s: READABLE_STRING_8
		do
			if attached o then
				s := o.out
				if attached {READABLE_STRING_32} s as s32 then
					Io.put_string_32 (s32)
				elseif attached {READABLE_STRING_8} s as s8 then
					Io.put_string (s8)
				else
					Io.put_string_32 (s.as_string_32)
				end
			end
		ensure -- from ANY
			instance_free: class
		end

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
		end
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		once
			create Result
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
		end
	
feature {NONE} -- Retrieval

	frozen internal_correct_mismatch
			-- Called from runtime to perform a proper dynamic dispatch on correct_mismatch
			-- from MISMATCH_CORRECTOR.
			-- (from ANY)
		local
			l_msg: STRING_32
			l_exc: EXCEPTIONS
		do
			if attached {MISMATCH_CORRECTOR} Current as l_corrector then
				l_corrector.correct_mismatch
			else
				create l_msg.make_from_string ("Mismatch: ".as_string_32)
				create l_exc;
				l_msg.append (generating_type.name_32);
				l_exc.raise_retrieval_exception (l_msg)
			end
		end
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

end -- class GAME_WINDOW_GL

Generated by ISE EiffelStudio