ruby-sdl-ffi 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,253 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+ module Gfx
33
+
34
+ M_PI = 3.141592654
35
+
36
+
37
+ func :pixelColor, [ :pointer, :int16, :int16, :uint32 ], :int
38
+
39
+ func :pixelRGBA,
40
+ [ :pointer, :int16, :int16, :uint8, :uint8, :uint8, :uint8 ], :int
41
+
42
+
43
+
44
+ func :hlineColor, [ :pointer, :int16, :int16, :int16, :uint32 ], :int
45
+
46
+ func :hlineRGBA,
47
+ [ :pointer, :int16, :int16, :int16,
48
+ :uint8, :uint8, :uint8, :uint8 ], :int
49
+
50
+ func :vlineColor, [ :pointer, :int16, :int16, :int16, :uint32 ], :int
51
+
52
+ func :vlineRGBA,
53
+ [ :pointer, :int16, :int16, :int16,
54
+ :uint8, :uint8, :uint8, :uint8 ], :int
55
+
56
+
57
+
58
+ func :rectangleColor,
59
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
60
+
61
+ func :rectangleRGBA,
62
+ [ :pointer, :int16, :int16,
63
+ :int16, :int16, :uint8, :uint8, :uint8, :uint8 ], :int
64
+
65
+ func :boxColor,
66
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
67
+
68
+ func :boxRGBA,
69
+ [ :pointer, :int16, :int16, :int16,
70
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
71
+
72
+
73
+
74
+ func :lineColor,
75
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
76
+
77
+ func :lineRGBA,
78
+ [ :pointer, :int16, :int16, :int16, :int16,
79
+ :uint8, :uint8, :uint8, :uint8 ], :int
80
+
81
+ func :aalineColor,
82
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
83
+
84
+ func :aalineRGBA,
85
+ [ :pointer, :int16, :int16, :int16, :int16,
86
+ :uint8, :uint8, :uint8, :uint8 ], :int
87
+
88
+
89
+
90
+ func :circleColor,
91
+ [ :pointer, :int16, :int16, :int16, :uint32 ], :int
92
+
93
+ func :circleRGBA,
94
+ [ :pointer, :int16, :int16, :int16,
95
+ :uint8, :uint8, :uint8, :uint8 ], :int
96
+
97
+
98
+
99
+ optfunc :arcColor,
100
+ [ :pointer, :int16, :int16, :int16,
101
+ :int16, :int16, :uint32 ], :int
102
+
103
+ func :arcRGBA,
104
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
105
+ :uint8, :uint8, :uint8, :uint8 ], :int
106
+
107
+
108
+
109
+ func :aacircleColor,
110
+ [ :pointer, :int16, :int16, :int16, :uint32 ], :int
111
+
112
+ func :aacircleRGBA,
113
+ [ :pointer, :int16, :int16, :int16,
114
+ :uint8, :uint8, :uint8, :uint8 ], :int
115
+
116
+ func :filledCircleColor,
117
+ [ :pointer, :int16, :int16, :int16, :uint32 ], :int
118
+
119
+ func :filledCircleRGBA,
120
+ [ :pointer, :int16, :int16, :int16,
121
+ :uint8, :uint8, :uint8, :uint8 ], :int
122
+
123
+
124
+
125
+ func :ellipseColor,
126
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
127
+
128
+ func :ellipseRGBA,
129
+ [ :pointer, :int16, :int16, :int16, :int16,
130
+ :uint8, :uint8, :uint8, :uint8 ], :int
131
+
132
+ func :aaellipseColor,
133
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
134
+
135
+ func :aaellipseRGBA,
136
+ [ :pointer, :int16, :int16, :int16, :int16,
137
+ :uint8, :uint8, :uint8, :uint8 ], :int
138
+
139
+ func :filledEllipseColor,
140
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
141
+
142
+ func :filledEllipseRGBA,
143
+ [ :pointer, :int16, :int16, :int16, :int16,
144
+ :uint8, :uint8, :uint8, :uint8 ], :int
145
+
146
+
147
+
148
+ func :pieColor,
149
+ [ :pointer, :int16, :int16, :int16, :int16, :int16, :uint32 ], :int
150
+
151
+ func :pieRGBA,
152
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
153
+ :uint8, :uint8, :uint8, :uint8 ], :int
154
+
155
+ func :filledPieColor,
156
+ [ :pointer, :int16, :int16, :int16, :int16, :int16, :uint32 ], :int
157
+
158
+ func :filledPieRGBA,
159
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
160
+ :uint8, :uint8, :uint8, :uint8 ], :int
161
+
162
+
163
+
164
+ func :trigonColor,
165
+ [ :pointer, :int16, :int16, :int16, :int16,
166
+ :int16, :int16, :uint32 ], :int
167
+
168
+ func :trigonRGBA,
169
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
170
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
171
+
172
+ func :aatrigonColor,
173
+ [ :pointer, :int16, :int16, :int16, :int16,
174
+ :int16, :int16, :uint32 ], :int
175
+
176
+ func :aatrigonRGBA,
177
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
178
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
179
+
180
+ func :filledTrigonColor,
181
+ [ :pointer, :int16, :int16, :int16, :int16,
182
+ :int16, :int16, :uint32 ], :int
183
+
184
+ func :filledTrigonRGBA,
185
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
186
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
187
+
188
+
189
+
190
+ func :polygonColor, [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
191
+
192
+ func :polygonRGBA,
193
+ [ :pointer, :pointer, :pointer, :int,
194
+ :uint8, :uint8, :uint8, :uint8 ], :int
195
+
196
+ func :aapolygonColor,
197
+ [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
198
+
199
+ func :aapolygonRGBA,
200
+ [ :pointer, :pointer, :pointer, :int,
201
+ :uint8, :uint8, :uint8, :uint8 ], :int
202
+
203
+ func :filledPolygonColor,
204
+ [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
205
+
206
+ func :filledPolygonRGBA,
207
+ [ :pointer, :pointer, :pointer, :int,
208
+ :uint8, :uint8, :uint8, :uint8 ], :int
209
+
210
+ optfunc :texturedPolygon,
211
+ [ :pointer, :pointer, :pointer,
212
+ :int, :pointer, :int, :int ], :int
213
+
214
+
215
+ optfunc :filledPolygonColorMT,
216
+ [ :pointer, :pointer, :pointer,
217
+ :int, :uint32, :pointer, :pointer ], :int
218
+
219
+ optfunc :filledPolygonRGBAMT,
220
+ [ :pointer, :pointer, :pointer, :int, :uint8,
221
+ :uint8, :uint8, :uint8, :pointer, :pointer ], :int
222
+
223
+ optfunc :texturedPolygonMT,
224
+ [ :pointer, :pointer, :pointer, :int,
225
+ :pointer, :int, :int, :pointer, :pointer ], :int
226
+
227
+
228
+
229
+ func :bezierColor,
230
+ [ :pointer, :pointer, :pointer, :int, :int, :uint32 ], :int
231
+
232
+ func :bezierRGBA,
233
+ [ :pointer, :pointer, :pointer, :int, :int,
234
+ :uint8, :uint8, :uint8, :uint8 ], :int
235
+
236
+
237
+
238
+ func :characterColor, [ :pointer, :int16, :int16, :char, :uint32 ], :int
239
+
240
+ func :characterRGBA,
241
+ [ :pointer, :int16, :int16, :char,
242
+ :uint8, :uint8, :uint8, :uint8 ], :int
243
+
244
+ func :stringColor, [ :pointer, :int16, :int16, :string, :uint32 ], :int
245
+
246
+ func :stringRGBA,
247
+ [ :pointer, :int16, :int16, :string,
248
+ :uint8, :uint8, :uint8, :uint8 ], :int
249
+
250
+ func :gfxPrimitivesSetFont, [ :pointer, :int, :int ], :void
251
+
252
+ end
253
+ end
@@ -0,0 +1,109 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ module SDL
32
+ module Gfx
33
+
34
+ SMOOTHING_OFF = 0
35
+ SMOOTHING_ON = 1
36
+
37
+
38
+ class TColorRGBA < NiceFFI::Struct
39
+ layout( :r, :uint8,
40
+ :g, :uint8,
41
+ :b, :uint8,
42
+ :a, :uint8 )
43
+ end
44
+
45
+
46
+ class TColorY < NiceFFI::Struct
47
+ layout( :y, :uint8 )
48
+ end
49
+
50
+
51
+
52
+ func :rotozoomSurface,
53
+ [ :pointer, :double, :double, :int ],
54
+ SDL::Surface.typed_pointer
55
+
56
+ func :__rotozoomSurfaceSize, :rotozoomSurfaceSize,
57
+ [ :int, :int, :double, :double, :pointer, :pointer ], :void
58
+
59
+ def self.rotozoomSurfaceSize( width, height, angle, zoom )
60
+ w = FFI::MemoryPointer.new( :int )
61
+ h = FFI::MemoryPointer.new( :int )
62
+ __rotozoomSurfaceSize( width, height, angle, zoom, w, h )
63
+ return [w.get_int(0), h.get_int(0)]
64
+ end
65
+
66
+
67
+ optfunc :rotozoomSurfaceXY,
68
+ [ :pointer, :double, :double, :double, :int ],
69
+ SDL::Surface.typed_pointer
70
+
71
+ optional {
72
+ func :__rotozoomSurfaceSizeXY, :rotozoomSurfaceSizeXY,
73
+ [ :int, :int, :double, :double, :double,
74
+ :pointer, :pointer ], :void
75
+
76
+ def self.rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy )
77
+ w = FFI::MemoryPointer.new( :int )
78
+ h = FFI::MemoryPointer.new( :int )
79
+ __rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy, w, h )
80
+ return [w.get_int(0), h.get_int(0)]
81
+ end
82
+ }
83
+
84
+
85
+ func :zoomSurface, [ :pointer, :double, :double, :int ],
86
+ SDL::Surface.typed_pointer
87
+
88
+
89
+ func :__zoomSurfaceSize, :zoomSurfaceSize,
90
+ [ :int, :int, :double, :double, :pointer, :pointer ], :void
91
+
92
+ def self.zoomSurfaceSize( width, height, zoomx, zoomy )
93
+ w = FFI::MemoryPointer.new( :int )
94
+ h = FFI::MemoryPointer.new( :int )
95
+ __zoomSurfaceSize( width, height, zoomx, zoomy, w, h )
96
+ return [w.get_int(0), h.get_int(0)]
97
+ end
98
+
99
+
100
+
101
+ optfunc :shrinkSurface, [ :pointer, :int, :int ],
102
+ SDL::Surface.typed_pointer
103
+
104
+
105
+ optfunc :rotateSurface90Degrees, [ :pointer, :int ],
106
+ SDL::Surface.typed_pointer
107
+
108
+ end
109
+ end
@@ -0,0 +1,90 @@
1
+ #--
2
+ #
3
+ # This file is one part of:
4
+ #
5
+ # Ruby-SDL-FFI - Ruby-FFI bindings to SDL
6
+ #
7
+ # Copyright (c) 2009 John Croisant
8
+ #
9
+ # Permission is hereby granted, free of charge, to any person obtaining
10
+ # a copy of this software and associated documentation files (the
11
+ # "Software"), to deal in the Software without restriction, including
12
+ # without limitation the rights to use, copy, modify, merge, publish,
13
+ # distribute, sublicense, and/or sell copies of the Software, and to
14
+ # permit persons to whom the Software is furnished to do so, subject to
15
+ # the following conditions:
16
+ #
17
+ # The above copyright notice and this permission notice shall be
18
+ # included in all copies or substantial portions of the Software.
19
+ #
20
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23
+ # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24
+ # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25
+ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26
+ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27
+ #
28
+ #++
29
+
30
+
31
+ this_dir = File.expand_path( File.dirname(__FILE__) )
32
+
33
+ require File.join( this_dir, "sdl" )
34
+
35
+
36
+ module SDL
37
+ module Image
38
+ extend NiceFFI::Library
39
+ load_library "SDL_image", SDL::LOAD_PATHS
40
+
41
+
42
+ def self.img_func( name, args, ret )
43
+ func name, "IMG_#{name}", args, ret
44
+ end
45
+
46
+
47
+ img_func :Linked_Version, [], SDL::Version.typed_pointer
48
+
49
+
50
+ img_func :LoadTyped_RW, [ :pointer, :int, :string ],
51
+ SDL::Surface.typed_pointer
52
+
53
+ img_func :Load, [ :string ], SDL::Surface.typed_pointer
54
+ img_func :Load_RW, [ :pointer, :int ], SDL::Surface.typed_pointer
55
+
56
+
57
+ img_func :InvertAlpha, [ :int ], :int
58
+
59
+
60
+ img_func :isBMP, [ :pointer ], :int
61
+ img_func :isGIF, [ :pointer ], :int
62
+ img_func :isJPG, [ :pointer ], :int
63
+ img_func :isLBM, [ :pointer ], :int
64
+ img_func :isPCX, [ :pointer ], :int
65
+ img_func :isPNG, [ :pointer ], :int
66
+ img_func :isPNM, [ :pointer ], :int
67
+ img_func :isTIF, [ :pointer ], :int
68
+ img_func :isXCF, [ :pointer ], :int
69
+ img_func :isXPM, [ :pointer ], :int
70
+ img_func :isXV, [ :pointer ], :int
71
+
72
+
73
+ img_func :LoadBMP_RW, [ :pointer ], SDL::Surface.typed_pointer
74
+ img_func :LoadGIF_RW, [ :pointer ], SDL::Surface.typed_pointer
75
+ img_func :LoadJPG_RW, [ :pointer ], SDL::Surface.typed_pointer
76
+ img_func :LoadLBM_RW, [ :pointer ], SDL::Surface.typed_pointer
77
+ img_func :LoadPCX_RW, [ :pointer ], SDL::Surface.typed_pointer
78
+ img_func :LoadPNG_RW, [ :pointer ], SDL::Surface.typed_pointer
79
+ img_func :LoadPNM_RW, [ :pointer ], SDL::Surface.typed_pointer
80
+ img_func :LoadTGA_RW, [ :pointer ], SDL::Surface.typed_pointer
81
+ img_func :LoadTIF_RW, [ :pointer ], SDL::Surface.typed_pointer
82
+ img_func :LoadXCF_RW, [ :pointer ], SDL::Surface.typed_pointer
83
+ img_func :LoadXPM_RW, [ :pointer ], SDL::Surface.typed_pointer
84
+ img_func :LoadXV_RW, [ :pointer ], SDL::Surface.typed_pointer
85
+
86
+
87
+ img_func :ReadXPMFromArray, [ :pointer ], SDL::Surface.typed_pointer
88
+
89
+ end
90
+ end