sdl2-bindings 0.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+
17
+ # Typedef
18
+
19
+ callback :SDL_TimerCallback, [:uint, :pointer], :uint
20
+ typedef :int, :SDL_TimerID
21
+
22
+ # Struct
23
+
24
+
25
+ # Function
26
+
27
+ def self.setup_timer_symbols()
28
+ symbols = [
29
+ :SDL_GetTicks,
30
+ :SDL_GetPerformanceCounter,
31
+ :SDL_GetPerformanceFrequency,
32
+ :SDL_Delay,
33
+ :SDL_AddTimer,
34
+ :SDL_RemoveTimer,
35
+ ]
36
+ args = {
37
+ :SDL_GetTicks => [],
38
+ :SDL_GetPerformanceCounter => [],
39
+ :SDL_GetPerformanceFrequency => [],
40
+ :SDL_Delay => [:uint],
41
+ :SDL_AddTimer => [:uint, :pointer, :pointer],
42
+ :SDL_RemoveTimer => [:int],
43
+ }
44
+ retvals = {
45
+ :SDL_GetTicks => :uint,
46
+ :SDL_GetPerformanceCounter => :ulong_long,
47
+ :SDL_GetPerformanceFrequency => :ulong_long,
48
+ :SDL_Delay => :void,
49
+ :SDL_AddTimer => :int,
50
+ :SDL_RemoveTimer => :int,
51
+ }
52
+ symbols.each do |sym|
53
+ begin
54
+ attach_function sym, args[sym], retvals[sym]
55
+ rescue FFI::NotFoundError => error
56
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+
@@ -0,0 +1,73 @@
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+
14
+ # Enum
15
+
16
+ SDL_TOUCH_DEVICE_INVALID = -1
17
+ SDL_TOUCH_DEVICE_DIRECT = 0
18
+ SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE = 1
19
+ SDL_TOUCH_DEVICE_INDIRECT_RELATIVE = 2
20
+
21
+ # Typedef
22
+
23
+ typedef :long_long, :SDL_TouchID
24
+ typedef :long_long, :SDL_FingerID
25
+ typedef :int, :SDL_TouchDeviceType
26
+
27
+ # Struct
28
+
29
+ class SDL_Finger < FFI::Struct
30
+ layout(
31
+ :id, :long_long,
32
+ :x, :float,
33
+ :y, :float,
34
+ :pressure, :float,
35
+ )
36
+ end
37
+
38
+
39
+ # Function
40
+
41
+ def self.setup_touch_symbols()
42
+ symbols = [
43
+ :SDL_GetNumTouchDevices,
44
+ :SDL_GetTouchDevice,
45
+ :SDL_GetTouchDeviceType,
46
+ :SDL_GetNumTouchFingers,
47
+ :SDL_GetTouchFinger,
48
+ ]
49
+ args = {
50
+ :SDL_GetNumTouchDevices => [],
51
+ :SDL_GetTouchDevice => [:int],
52
+ :SDL_GetTouchDeviceType => [:long_long],
53
+ :SDL_GetNumTouchFingers => [:long_long],
54
+ :SDL_GetTouchFinger => [:long_long, :int],
55
+ }
56
+ retvals = {
57
+ :SDL_GetNumTouchDevices => :int,
58
+ :SDL_GetTouchDevice => :long_long,
59
+ :SDL_GetTouchDeviceType => :int,
60
+ :SDL_GetNumTouchFingers => :int,
61
+ :SDL_GetTouchFinger => :pointer,
62
+ }
63
+ symbols.each do |sym|
64
+ begin
65
+ attach_function sym, args[sym], retvals[sym]
66
+ rescue FFI::NotFoundError => error
67
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
68
+ end
69
+ end
70
+ end
71
+
72
+ end
73
+
@@ -0,0 +1,190 @@
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+ require_relative 'sdl2_pixels'
9
+
10
+ module SDL2
11
+ extend FFI::Library
12
+ # Define/Macro
13
+
14
+ SDL_TTF_MAJOR_VERSION = 2
15
+ SDL_TTF_MINOR_VERSION = 0
16
+ SDL_TTF_PATCHLEVEL = 15
17
+
18
+ # Enum
19
+
20
+
21
+ # Typedef
22
+
23
+
24
+ # Struct
25
+
26
+
27
+ # Function
28
+
29
+ def self.setup_ttf_symbols()
30
+ symbols = [
31
+ :TTF_Linked_Version,
32
+ :TTF_ByteSwappedUNICODE,
33
+ :TTF_Init,
34
+ :TTF_OpenFont,
35
+ :TTF_OpenFontIndex,
36
+ :TTF_OpenFontRW,
37
+ :TTF_OpenFontIndexRW,
38
+ :TTF_GetFontStyle,
39
+ :TTF_SetFontStyle,
40
+ :TTF_GetFontOutline,
41
+ :TTF_SetFontOutline,
42
+ :TTF_GetFontHinting,
43
+ :TTF_SetFontHinting,
44
+ :TTF_FontHeight,
45
+ :TTF_FontAscent,
46
+ :TTF_FontDescent,
47
+ :TTF_FontLineSkip,
48
+ :TTF_GetFontKerning,
49
+ :TTF_SetFontKerning,
50
+ :TTF_FontFaces,
51
+ :TTF_FontFaceIsFixedWidth,
52
+ :TTF_FontFaceFamilyName,
53
+ :TTF_FontFaceStyleName,
54
+ :TTF_GlyphIsProvided,
55
+ :TTF_GlyphMetrics,
56
+ :TTF_SizeText,
57
+ :TTF_SizeUTF8,
58
+ :TTF_SizeUNICODE,
59
+ :TTF_RenderText_Solid,
60
+ :TTF_RenderUTF8_Solid,
61
+ :TTF_RenderUNICODE_Solid,
62
+ :TTF_RenderGlyph_Solid,
63
+ :TTF_RenderText_Shaded,
64
+ :TTF_RenderUTF8_Shaded,
65
+ :TTF_RenderUNICODE_Shaded,
66
+ :TTF_RenderGlyph_Shaded,
67
+ :TTF_RenderText_Blended,
68
+ :TTF_RenderUTF8_Blended,
69
+ :TTF_RenderUNICODE_Blended,
70
+ :TTF_RenderText_Blended_Wrapped,
71
+ :TTF_RenderUTF8_Blended_Wrapped,
72
+ :TTF_RenderUNICODE_Blended_Wrapped,
73
+ :TTF_RenderGlyph_Blended,
74
+ :TTF_CloseFont,
75
+ :TTF_Quit,
76
+ :TTF_WasInit,
77
+ :TTF_GetFontKerningSize,
78
+ :TTF_GetFontKerningSizeGlyphs,
79
+ ]
80
+ args = {
81
+ :TTF_Linked_Version => [],
82
+ :TTF_ByteSwappedUNICODE => [:int],
83
+ :TTF_Init => [],
84
+ :TTF_OpenFont => [:pointer, :int],
85
+ :TTF_OpenFontIndex => [:pointer, :int, :long],
86
+ :TTF_OpenFontRW => [:pointer, :int, :int],
87
+ :TTF_OpenFontIndexRW => [:pointer, :int, :int, :long],
88
+ :TTF_GetFontStyle => [:pointer],
89
+ :TTF_SetFontStyle => [:pointer, :int],
90
+ :TTF_GetFontOutline => [:pointer],
91
+ :TTF_SetFontOutline => [:pointer, :int],
92
+ :TTF_GetFontHinting => [:pointer],
93
+ :TTF_SetFontHinting => [:pointer, :int],
94
+ :TTF_FontHeight => [:pointer],
95
+ :TTF_FontAscent => [:pointer],
96
+ :TTF_FontDescent => [:pointer],
97
+ :TTF_FontLineSkip => [:pointer],
98
+ :TTF_GetFontKerning => [:pointer],
99
+ :TTF_SetFontKerning => [:pointer, :int],
100
+ :TTF_FontFaces => [:pointer],
101
+ :TTF_FontFaceIsFixedWidth => [:pointer],
102
+ :TTF_FontFaceFamilyName => [:pointer],
103
+ :TTF_FontFaceStyleName => [:pointer],
104
+ :TTF_GlyphIsProvided => [:pointer, :ushort],
105
+ :TTF_GlyphMetrics => [:pointer, :ushort, :pointer, :pointer, :pointer, :pointer, :pointer],
106
+ :TTF_SizeText => [:pointer, :pointer, :pointer, :pointer],
107
+ :TTF_SizeUTF8 => [:pointer, :pointer, :pointer, :pointer],
108
+ :TTF_SizeUNICODE => [:pointer, :pointer, :pointer, :pointer],
109
+ :TTF_RenderText_Solid => [:pointer, :pointer, SDL_Color],
110
+ :TTF_RenderUTF8_Solid => [:pointer, :pointer, SDL_Color],
111
+ :TTF_RenderUNICODE_Solid => [:pointer, :pointer, SDL_Color],
112
+ :TTF_RenderGlyph_Solid => [:pointer, :ushort, SDL_Color],
113
+ :TTF_RenderText_Shaded => [:pointer, :pointer, SDL_Color, SDL_Color],
114
+ :TTF_RenderUTF8_Shaded => [:pointer, :pointer, SDL_Color, SDL_Color],
115
+ :TTF_RenderUNICODE_Shaded => [:pointer, :pointer, SDL_Color, SDL_Color],
116
+ :TTF_RenderGlyph_Shaded => [:pointer, :ushort, SDL_Color, SDL_Color],
117
+ :TTF_RenderText_Blended => [:pointer, :pointer, SDL_Color],
118
+ :TTF_RenderUTF8_Blended => [:pointer, :pointer, SDL_Color],
119
+ :TTF_RenderUNICODE_Blended => [:pointer, :pointer, SDL_Color],
120
+ :TTF_RenderText_Blended_Wrapped => [:pointer, :pointer, SDL_Color, :uint],
121
+ :TTF_RenderUTF8_Blended_Wrapped => [:pointer, :pointer, SDL_Color, :uint],
122
+ :TTF_RenderUNICODE_Blended_Wrapped => [:pointer, :pointer, SDL_Color, :uint],
123
+ :TTF_RenderGlyph_Blended => [:pointer, :ushort, SDL_Color],
124
+ :TTF_CloseFont => [:pointer],
125
+ :TTF_Quit => [],
126
+ :TTF_WasInit => [],
127
+ :TTF_GetFontKerningSize => [:pointer, :int, :int],
128
+ :TTF_GetFontKerningSizeGlyphs => [:pointer, :ushort, :ushort],
129
+ }
130
+ retvals = {
131
+ :TTF_Linked_Version => :pointer,
132
+ :TTF_ByteSwappedUNICODE => :void,
133
+ :TTF_Init => :int,
134
+ :TTF_OpenFont => :pointer,
135
+ :TTF_OpenFontIndex => :pointer,
136
+ :TTF_OpenFontRW => :pointer,
137
+ :TTF_OpenFontIndexRW => :pointer,
138
+ :TTF_GetFontStyle => :int,
139
+ :TTF_SetFontStyle => :void,
140
+ :TTF_GetFontOutline => :int,
141
+ :TTF_SetFontOutline => :void,
142
+ :TTF_GetFontHinting => :int,
143
+ :TTF_SetFontHinting => :void,
144
+ :TTF_FontHeight => :int,
145
+ :TTF_FontAscent => :int,
146
+ :TTF_FontDescent => :int,
147
+ :TTF_FontLineSkip => :int,
148
+ :TTF_GetFontKerning => :int,
149
+ :TTF_SetFontKerning => :void,
150
+ :TTF_FontFaces => :long,
151
+ :TTF_FontFaceIsFixedWidth => :int,
152
+ :TTF_FontFaceFamilyName => :pointer,
153
+ :TTF_FontFaceStyleName => :pointer,
154
+ :TTF_GlyphIsProvided => :int,
155
+ :TTF_GlyphMetrics => :int,
156
+ :TTF_SizeText => :int,
157
+ :TTF_SizeUTF8 => :int,
158
+ :TTF_SizeUNICODE => :int,
159
+ :TTF_RenderText_Solid => :pointer,
160
+ :TTF_RenderUTF8_Solid => :pointer,
161
+ :TTF_RenderUNICODE_Solid => :pointer,
162
+ :TTF_RenderGlyph_Solid => :pointer,
163
+ :TTF_RenderText_Shaded => :pointer,
164
+ :TTF_RenderUTF8_Shaded => :pointer,
165
+ :TTF_RenderUNICODE_Shaded => :pointer,
166
+ :TTF_RenderGlyph_Shaded => :pointer,
167
+ :TTF_RenderText_Blended => :pointer,
168
+ :TTF_RenderUTF8_Blended => :pointer,
169
+ :TTF_RenderUNICODE_Blended => :pointer,
170
+ :TTF_RenderText_Blended_Wrapped => :pointer,
171
+ :TTF_RenderUTF8_Blended_Wrapped => :pointer,
172
+ :TTF_RenderUNICODE_Blended_Wrapped => :pointer,
173
+ :TTF_RenderGlyph_Blended => :pointer,
174
+ :TTF_CloseFont => :void,
175
+ :TTF_Quit => :void,
176
+ :TTF_WasInit => :int,
177
+ :TTF_GetFontKerningSize => :int,
178
+ :TTF_GetFontKerningSizeGlyphs => :int,
179
+ }
180
+ symbols.each do |sym|
181
+ begin
182
+ attach_function sym, args[sym], retvals[sym]
183
+ rescue FFI::NotFoundError => error
184
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
185
+ end
186
+ end
187
+ end
188
+
189
+ end
190
+
@@ -0,0 +1,62 @@
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ SDL_MAJOR_VERSION = 2
14
+ SDL_MINOR_VERSION = 0
15
+ SDL_PATCHLEVEL = 10
16
+
17
+ # Enum
18
+
19
+
20
+ # Typedef
21
+
22
+
23
+ # Struct
24
+
25
+ class SDL_version < FFI::Struct
26
+ layout(
27
+ :major, :uchar,
28
+ :minor, :uchar,
29
+ :patch, :uchar,
30
+ )
31
+ end
32
+
33
+
34
+ # Function
35
+
36
+ def self.setup_version_symbols()
37
+ symbols = [
38
+ :SDL_GetVersion,
39
+ :SDL_GetRevision,
40
+ :SDL_GetRevisionNumber,
41
+ ]
42
+ args = {
43
+ :SDL_GetVersion => [:pointer],
44
+ :SDL_GetRevision => [],
45
+ :SDL_GetRevisionNumber => [],
46
+ }
47
+ retvals = {
48
+ :SDL_GetVersion => :void,
49
+ :SDL_GetRevision => :pointer,
50
+ :SDL_GetRevisionNumber => :int,
51
+ }
52
+ symbols.each do |sym|
53
+ begin
54
+ attach_function sym, args[sym], retvals[sym]
55
+ rescue FFI::NotFoundError => error
56
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+
@@ -0,0 +1,408 @@
1
+ # Ruby-SDL2 : Yet another SDL2 wrapper for Ruby
2
+ #
3
+ # * https://github.com/vaiorabbit/sdl2-bindings
4
+ #
5
+ # [NOTICE] This is an automatically generated file.
6
+
7
+ require 'ffi'
8
+
9
+ module SDL2
10
+ extend FFI::Library
11
+ # Define/Macro
12
+
13
+ SDL_WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000
14
+ SDL_WINDOWPOS_CENTERED_MASK = 0x2FFF0000
15
+
16
+ # Enum
17
+
18
+ SDL_WINDOW_FULLSCREEN = 1
19
+ SDL_WINDOW_OPENGL = 2
20
+ SDL_WINDOW_SHOWN = 4
21
+ SDL_WINDOW_HIDDEN = 8
22
+ SDL_WINDOW_BORDERLESS = 16
23
+ SDL_WINDOW_RESIZABLE = 32
24
+ SDL_WINDOW_MINIMIZED = 64
25
+ SDL_WINDOW_MAXIMIZED = 128
26
+ SDL_WINDOW_INPUT_GRABBED = 256
27
+ SDL_WINDOW_INPUT_FOCUS = 512
28
+ SDL_WINDOW_MOUSE_FOCUS = 1024
29
+ SDL_WINDOW_FULLSCREEN_DESKTOP = 4097
30
+ SDL_WINDOW_FOREIGN = 2048
31
+ SDL_WINDOW_ALLOW_HIGHDPI = 8192
32
+ SDL_WINDOW_MOUSE_CAPTURE = 16384
33
+ SDL_WINDOW_ALWAYS_ON_TOP = 32768
34
+ SDL_WINDOW_SKIP_TASKBAR = 65536
35
+ SDL_WINDOW_UTILITY = 131072
36
+ SDL_WINDOW_TOOLTIP = 262144
37
+ SDL_WINDOW_POPUP_MENU = 524288
38
+ SDL_WINDOW_VULKAN = 268435456
39
+ SDL_WINDOWEVENT_NONE = 0
40
+ SDL_WINDOWEVENT_SHOWN = 1
41
+ SDL_WINDOWEVENT_HIDDEN = 2
42
+ SDL_WINDOWEVENT_EXPOSED = 3
43
+ SDL_WINDOWEVENT_MOVED = 4
44
+ SDL_WINDOWEVENT_RESIZED = 5
45
+ SDL_WINDOWEVENT_SIZE_CHANGED = 6
46
+ SDL_WINDOWEVENT_MINIMIZED = 7
47
+ SDL_WINDOWEVENT_MAXIMIZED = 8
48
+ SDL_WINDOWEVENT_RESTORED = 9
49
+ SDL_WINDOWEVENT_ENTER = 10
50
+ SDL_WINDOWEVENT_LEAVE = 11
51
+ SDL_WINDOWEVENT_FOCUS_GAINED = 12
52
+ SDL_WINDOWEVENT_FOCUS_LOST = 13
53
+ SDL_WINDOWEVENT_CLOSE = 14
54
+ SDL_WINDOWEVENT_TAKE_FOCUS = 15
55
+ SDL_WINDOWEVENT_HIT_TEST = 16
56
+ SDL_DISPLAYEVENT_NONE = 0
57
+ SDL_DISPLAYEVENT_ORIENTATION = 1
58
+ SDL_ORIENTATION_UNKNOWN = 0
59
+ SDL_ORIENTATION_LANDSCAPE = 1
60
+ SDL_ORIENTATION_LANDSCAPE_FLIPPED = 2
61
+ SDL_ORIENTATION_PORTRAIT = 3
62
+ SDL_ORIENTATION_PORTRAIT_FLIPPED = 4
63
+ SDL_GL_RED_SIZE = 0
64
+ SDL_GL_GREEN_SIZE = 1
65
+ SDL_GL_BLUE_SIZE = 2
66
+ SDL_GL_ALPHA_SIZE = 3
67
+ SDL_GL_BUFFER_SIZE = 4
68
+ SDL_GL_DOUBLEBUFFER = 5
69
+ SDL_GL_DEPTH_SIZE = 6
70
+ SDL_GL_STENCIL_SIZE = 7
71
+ SDL_GL_ACCUM_RED_SIZE = 8
72
+ SDL_GL_ACCUM_GREEN_SIZE = 9
73
+ SDL_GL_ACCUM_BLUE_SIZE = 10
74
+ SDL_GL_ACCUM_ALPHA_SIZE = 11
75
+ SDL_GL_STEREO = 12
76
+ SDL_GL_MULTISAMPLEBUFFERS = 13
77
+ SDL_GL_MULTISAMPLESAMPLES = 14
78
+ SDL_GL_ACCELERATED_VISUAL = 15
79
+ SDL_GL_RETAINED_BACKING = 16
80
+ SDL_GL_CONTEXT_MAJOR_VERSION = 17
81
+ SDL_GL_CONTEXT_MINOR_VERSION = 18
82
+ SDL_GL_CONTEXT_EGL = 19
83
+ SDL_GL_CONTEXT_FLAGS = 20
84
+ SDL_GL_CONTEXT_PROFILE_MASK = 21
85
+ SDL_GL_SHARE_WITH_CURRENT_CONTEXT = 22
86
+ SDL_GL_FRAMEBUFFER_SRGB_CAPABLE = 23
87
+ SDL_GL_CONTEXT_RELEASE_BEHAVIOR = 24
88
+ SDL_GL_CONTEXT_RESET_NOTIFICATION = 25
89
+ SDL_GL_CONTEXT_NO_ERROR = 26
90
+ SDL_GL_CONTEXT_PROFILE_CORE = 1
91
+ SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 2
92
+ SDL_GL_CONTEXT_PROFILE_ES = 4
93
+ SDL_GL_CONTEXT_DEBUG_FLAG = 1
94
+ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 2
95
+ SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 4
96
+ SDL_GL_CONTEXT_RESET_ISOLATION_FLAG = 8
97
+ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE = 0
98
+ SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH = 1
99
+ SDL_GL_CONTEXT_RESET_NO_NOTIFICATION = 0
100
+ SDL_GL_CONTEXT_RESET_LOSE_CONTEXT = 1
101
+ SDL_HITTEST_NORMAL = 0
102
+ SDL_HITTEST_DRAGGABLE = 1
103
+ SDL_HITTEST_RESIZE_TOPLEFT = 2
104
+ SDL_HITTEST_RESIZE_TOP = 3
105
+ SDL_HITTEST_RESIZE_TOPRIGHT = 4
106
+ SDL_HITTEST_RESIZE_RIGHT = 5
107
+ SDL_HITTEST_RESIZE_BOTTOMRIGHT = 6
108
+ SDL_HITTEST_RESIZE_BOTTOM = 7
109
+ SDL_HITTEST_RESIZE_BOTTOMLEFT = 8
110
+ SDL_HITTEST_RESIZE_LEFT = 9
111
+
112
+ # Typedef
113
+
114
+ typedef :int, :SDL_WindowFlags
115
+ typedef :int, :SDL_WindowEventID
116
+ typedef :int, :SDL_DisplayEventID
117
+ typedef :int, :SDL_DisplayOrientation
118
+ typedef :pointer, :SDL_GLContext
119
+ typedef :int, :SDL_GLattr
120
+ typedef :int, :SDL_GLprofile
121
+ typedef :int, :SDL_GLcontextFlag
122
+ typedef :int, :SDL_GLcontextReleaseFlag
123
+ typedef :int, :SDL_GLContextResetNotification
124
+ typedef :int, :SDL_HitTestResult
125
+ callback :SDL_HitTest, [:pointer, :pointer, :pointer], :int
126
+
127
+ # Struct
128
+
129
+ class SDL_DisplayMode < FFI::Struct
130
+ layout(
131
+ :format, :uint,
132
+ :w, :int,
133
+ :h, :int,
134
+ :refresh_rate, :int,
135
+ :driverdata, :pointer,
136
+ )
137
+ end
138
+
139
+
140
+ # Function
141
+
142
+ def self.setup_video_symbols()
143
+ symbols = [
144
+ :SDL_GetNumVideoDrivers,
145
+ :SDL_GetVideoDriver,
146
+ :SDL_VideoInit,
147
+ :SDL_VideoQuit,
148
+ :SDL_GetCurrentVideoDriver,
149
+ :SDL_GetNumVideoDisplays,
150
+ :SDL_GetDisplayName,
151
+ :SDL_GetDisplayBounds,
152
+ :SDL_GetDisplayUsableBounds,
153
+ :SDL_GetDisplayDPI,
154
+ :SDL_GetDisplayOrientation,
155
+ :SDL_GetNumDisplayModes,
156
+ :SDL_GetDisplayMode,
157
+ :SDL_GetDesktopDisplayMode,
158
+ :SDL_GetCurrentDisplayMode,
159
+ :SDL_GetClosestDisplayMode,
160
+ :SDL_GetWindowDisplayIndex,
161
+ :SDL_SetWindowDisplayMode,
162
+ :SDL_GetWindowDisplayMode,
163
+ :SDL_GetWindowPixelFormat,
164
+ :SDL_CreateWindow,
165
+ :SDL_CreateWindowFrom,
166
+ :SDL_GetWindowID,
167
+ :SDL_GetWindowFromID,
168
+ :SDL_GetWindowFlags,
169
+ :SDL_SetWindowTitle,
170
+ :SDL_GetWindowTitle,
171
+ :SDL_SetWindowIcon,
172
+ :SDL_SetWindowData,
173
+ :SDL_GetWindowData,
174
+ :SDL_SetWindowPosition,
175
+ :SDL_GetWindowPosition,
176
+ :SDL_SetWindowSize,
177
+ :SDL_GetWindowSize,
178
+ :SDL_GetWindowBordersSize,
179
+ :SDL_SetWindowMinimumSize,
180
+ :SDL_GetWindowMinimumSize,
181
+ :SDL_SetWindowMaximumSize,
182
+ :SDL_GetWindowMaximumSize,
183
+ :SDL_SetWindowBordered,
184
+ :SDL_SetWindowResizable,
185
+ :SDL_ShowWindow,
186
+ :SDL_HideWindow,
187
+ :SDL_RaiseWindow,
188
+ :SDL_MaximizeWindow,
189
+ :SDL_MinimizeWindow,
190
+ :SDL_RestoreWindow,
191
+ :SDL_SetWindowFullscreen,
192
+ :SDL_GetWindowSurface,
193
+ :SDL_UpdateWindowSurface,
194
+ :SDL_UpdateWindowSurfaceRects,
195
+ :SDL_SetWindowGrab,
196
+ :SDL_GetWindowGrab,
197
+ :SDL_GetGrabbedWindow,
198
+ :SDL_SetWindowBrightness,
199
+ :SDL_GetWindowBrightness,
200
+ :SDL_SetWindowOpacity,
201
+ :SDL_GetWindowOpacity,
202
+ :SDL_SetWindowModalFor,
203
+ :SDL_SetWindowInputFocus,
204
+ :SDL_SetWindowGammaRamp,
205
+ :SDL_GetWindowGammaRamp,
206
+ :SDL_SetWindowHitTest,
207
+ :SDL_DestroyWindow,
208
+ :SDL_IsScreenSaverEnabled,
209
+ :SDL_EnableScreenSaver,
210
+ :SDL_DisableScreenSaver,
211
+ :SDL_GL_LoadLibrary,
212
+ :SDL_GL_GetProcAddress,
213
+ :SDL_GL_UnloadLibrary,
214
+ :SDL_GL_ExtensionSupported,
215
+ :SDL_GL_ResetAttributes,
216
+ :SDL_GL_SetAttribute,
217
+ :SDL_GL_GetAttribute,
218
+ :SDL_GL_CreateContext,
219
+ :SDL_GL_MakeCurrent,
220
+ :SDL_GL_GetCurrentWindow,
221
+ :SDL_GL_GetCurrentContext,
222
+ :SDL_GL_GetDrawableSize,
223
+ :SDL_GL_SetSwapInterval,
224
+ :SDL_GL_GetSwapInterval,
225
+ :SDL_GL_SwapWindow,
226
+ :SDL_GL_DeleteContext,
227
+ ]
228
+ args = {
229
+ :SDL_GetNumVideoDrivers => [],
230
+ :SDL_GetVideoDriver => [:int],
231
+ :SDL_VideoInit => [:pointer],
232
+ :SDL_VideoQuit => [],
233
+ :SDL_GetCurrentVideoDriver => [],
234
+ :SDL_GetNumVideoDisplays => [],
235
+ :SDL_GetDisplayName => [:int],
236
+ :SDL_GetDisplayBounds => [:int, :pointer],
237
+ :SDL_GetDisplayUsableBounds => [:int, :pointer],
238
+ :SDL_GetDisplayDPI => [:int, :pointer, :pointer, :pointer],
239
+ :SDL_GetDisplayOrientation => [:int],
240
+ :SDL_GetNumDisplayModes => [:int],
241
+ :SDL_GetDisplayMode => [:int, :int, :pointer],
242
+ :SDL_GetDesktopDisplayMode => [:int, :pointer],
243
+ :SDL_GetCurrentDisplayMode => [:int, :pointer],
244
+ :SDL_GetClosestDisplayMode => [:int, :pointer, :pointer],
245
+ :SDL_GetWindowDisplayIndex => [:pointer],
246
+ :SDL_SetWindowDisplayMode => [:pointer, :pointer],
247
+ :SDL_GetWindowDisplayMode => [:pointer, :pointer],
248
+ :SDL_GetWindowPixelFormat => [:pointer],
249
+ :SDL_CreateWindow => [:pointer, :int, :int, :int, :int, :uint],
250
+ :SDL_CreateWindowFrom => [:pointer],
251
+ :SDL_GetWindowID => [:pointer],
252
+ :SDL_GetWindowFromID => [:uint],
253
+ :SDL_GetWindowFlags => [:pointer],
254
+ :SDL_SetWindowTitle => [:pointer, :pointer],
255
+ :SDL_GetWindowTitle => [:pointer],
256
+ :SDL_SetWindowIcon => [:pointer, :pointer],
257
+ :SDL_SetWindowData => [:pointer, :pointer, :pointer],
258
+ :SDL_GetWindowData => [:pointer, :pointer],
259
+ :SDL_SetWindowPosition => [:pointer, :int, :int],
260
+ :SDL_GetWindowPosition => [:pointer, :pointer, :pointer],
261
+ :SDL_SetWindowSize => [:pointer, :int, :int],
262
+ :SDL_GetWindowSize => [:pointer, :pointer, :pointer],
263
+ :SDL_GetWindowBordersSize => [:pointer, :pointer, :pointer, :pointer, :pointer],
264
+ :SDL_SetWindowMinimumSize => [:pointer, :int, :int],
265
+ :SDL_GetWindowMinimumSize => [:pointer, :pointer, :pointer],
266
+ :SDL_SetWindowMaximumSize => [:pointer, :int, :int],
267
+ :SDL_GetWindowMaximumSize => [:pointer, :pointer, :pointer],
268
+ :SDL_SetWindowBordered => [:pointer, :int],
269
+ :SDL_SetWindowResizable => [:pointer, :int],
270
+ :SDL_ShowWindow => [:pointer],
271
+ :SDL_HideWindow => [:pointer],
272
+ :SDL_RaiseWindow => [:pointer],
273
+ :SDL_MaximizeWindow => [:pointer],
274
+ :SDL_MinimizeWindow => [:pointer],
275
+ :SDL_RestoreWindow => [:pointer],
276
+ :SDL_SetWindowFullscreen => [:pointer, :uint],
277
+ :SDL_GetWindowSurface => [:pointer],
278
+ :SDL_UpdateWindowSurface => [:pointer],
279
+ :SDL_UpdateWindowSurfaceRects => [:pointer, :pointer, :int],
280
+ :SDL_SetWindowGrab => [:pointer, :int],
281
+ :SDL_GetWindowGrab => [:pointer],
282
+ :SDL_GetGrabbedWindow => [],
283
+ :SDL_SetWindowBrightness => [:pointer, :float],
284
+ :SDL_GetWindowBrightness => [:pointer],
285
+ :SDL_SetWindowOpacity => [:pointer, :float],
286
+ :SDL_GetWindowOpacity => [:pointer, :pointer],
287
+ :SDL_SetWindowModalFor => [:pointer, :pointer],
288
+ :SDL_SetWindowInputFocus => [:pointer],
289
+ :SDL_SetWindowGammaRamp => [:pointer, :pointer, :pointer, :pointer],
290
+ :SDL_GetWindowGammaRamp => [:pointer, :pointer, :pointer, :pointer],
291
+ :SDL_SetWindowHitTest => [:pointer, :pointer, :pointer],
292
+ :SDL_DestroyWindow => [:pointer],
293
+ :SDL_IsScreenSaverEnabled => [],
294
+ :SDL_EnableScreenSaver => [],
295
+ :SDL_DisableScreenSaver => [],
296
+ :SDL_GL_LoadLibrary => [:pointer],
297
+ :SDL_GL_GetProcAddress => [:pointer],
298
+ :SDL_GL_UnloadLibrary => [],
299
+ :SDL_GL_ExtensionSupported => [:pointer],
300
+ :SDL_GL_ResetAttributes => [],
301
+ :SDL_GL_SetAttribute => [:int, :int],
302
+ :SDL_GL_GetAttribute => [:int, :pointer],
303
+ :SDL_GL_CreateContext => [:pointer],
304
+ :SDL_GL_MakeCurrent => [:pointer, :pointer],
305
+ :SDL_GL_GetCurrentWindow => [],
306
+ :SDL_GL_GetCurrentContext => [],
307
+ :SDL_GL_GetDrawableSize => [:pointer, :pointer, :pointer],
308
+ :SDL_GL_SetSwapInterval => [:int],
309
+ :SDL_GL_GetSwapInterval => [],
310
+ :SDL_GL_SwapWindow => [:pointer],
311
+ :SDL_GL_DeleteContext => [:pointer],
312
+ }
313
+ retvals = {
314
+ :SDL_GetNumVideoDrivers => :int,
315
+ :SDL_GetVideoDriver => :pointer,
316
+ :SDL_VideoInit => :int,
317
+ :SDL_VideoQuit => :void,
318
+ :SDL_GetCurrentVideoDriver => :pointer,
319
+ :SDL_GetNumVideoDisplays => :int,
320
+ :SDL_GetDisplayName => :pointer,
321
+ :SDL_GetDisplayBounds => :int,
322
+ :SDL_GetDisplayUsableBounds => :int,
323
+ :SDL_GetDisplayDPI => :int,
324
+ :SDL_GetDisplayOrientation => :int,
325
+ :SDL_GetNumDisplayModes => :int,
326
+ :SDL_GetDisplayMode => :int,
327
+ :SDL_GetDesktopDisplayMode => :int,
328
+ :SDL_GetCurrentDisplayMode => :int,
329
+ :SDL_GetClosestDisplayMode => :pointer,
330
+ :SDL_GetWindowDisplayIndex => :int,
331
+ :SDL_SetWindowDisplayMode => :int,
332
+ :SDL_GetWindowDisplayMode => :int,
333
+ :SDL_GetWindowPixelFormat => :uint,
334
+ :SDL_CreateWindow => :pointer,
335
+ :SDL_CreateWindowFrom => :pointer,
336
+ :SDL_GetWindowID => :uint,
337
+ :SDL_GetWindowFromID => :pointer,
338
+ :SDL_GetWindowFlags => :uint,
339
+ :SDL_SetWindowTitle => :void,
340
+ :SDL_GetWindowTitle => :pointer,
341
+ :SDL_SetWindowIcon => :void,
342
+ :SDL_SetWindowData => :pointer,
343
+ :SDL_GetWindowData => :pointer,
344
+ :SDL_SetWindowPosition => :void,
345
+ :SDL_GetWindowPosition => :void,
346
+ :SDL_SetWindowSize => :void,
347
+ :SDL_GetWindowSize => :void,
348
+ :SDL_GetWindowBordersSize => :int,
349
+ :SDL_SetWindowMinimumSize => :void,
350
+ :SDL_GetWindowMinimumSize => :void,
351
+ :SDL_SetWindowMaximumSize => :void,
352
+ :SDL_GetWindowMaximumSize => :void,
353
+ :SDL_SetWindowBordered => :void,
354
+ :SDL_SetWindowResizable => :void,
355
+ :SDL_ShowWindow => :void,
356
+ :SDL_HideWindow => :void,
357
+ :SDL_RaiseWindow => :void,
358
+ :SDL_MaximizeWindow => :void,
359
+ :SDL_MinimizeWindow => :void,
360
+ :SDL_RestoreWindow => :void,
361
+ :SDL_SetWindowFullscreen => :int,
362
+ :SDL_GetWindowSurface => :pointer,
363
+ :SDL_UpdateWindowSurface => :int,
364
+ :SDL_UpdateWindowSurfaceRects => :int,
365
+ :SDL_SetWindowGrab => :void,
366
+ :SDL_GetWindowGrab => :int,
367
+ :SDL_GetGrabbedWindow => :pointer,
368
+ :SDL_SetWindowBrightness => :int,
369
+ :SDL_GetWindowBrightness => :float,
370
+ :SDL_SetWindowOpacity => :int,
371
+ :SDL_GetWindowOpacity => :int,
372
+ :SDL_SetWindowModalFor => :int,
373
+ :SDL_SetWindowInputFocus => :int,
374
+ :SDL_SetWindowGammaRamp => :int,
375
+ :SDL_GetWindowGammaRamp => :int,
376
+ :SDL_SetWindowHitTest => :int,
377
+ :SDL_DestroyWindow => :void,
378
+ :SDL_IsScreenSaverEnabled => :int,
379
+ :SDL_EnableScreenSaver => :void,
380
+ :SDL_DisableScreenSaver => :void,
381
+ :SDL_GL_LoadLibrary => :int,
382
+ :SDL_GL_GetProcAddress => :pointer,
383
+ :SDL_GL_UnloadLibrary => :void,
384
+ :SDL_GL_ExtensionSupported => :int,
385
+ :SDL_GL_ResetAttributes => :void,
386
+ :SDL_GL_SetAttribute => :int,
387
+ :SDL_GL_GetAttribute => :int,
388
+ :SDL_GL_CreateContext => :pointer,
389
+ :SDL_GL_MakeCurrent => :int,
390
+ :SDL_GL_GetCurrentWindow => :pointer,
391
+ :SDL_GL_GetCurrentContext => :pointer,
392
+ :SDL_GL_GetDrawableSize => :void,
393
+ :SDL_GL_SetSwapInterval => :int,
394
+ :SDL_GL_GetSwapInterval => :int,
395
+ :SDL_GL_SwapWindow => :void,
396
+ :SDL_GL_DeleteContext => :void,
397
+ }
398
+ symbols.each do |sym|
399
+ begin
400
+ attach_function sym, args[sym], retvals[sym]
401
+ rescue FFI::NotFoundError => error
402
+ $stderr.puts("[Warning] Failed to import #{sym} (#{error}).")
403
+ end
404
+ end
405
+ end
406
+
407
+ end
408
+