misha-ruby-sdl-ffi 0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,251 @@
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
+ func :aacircleColor,
98
+ [ :pointer, :int16, :int16, :int16, :uint32 ], :int
99
+
100
+ func :aacircleRGBA,
101
+ [ :pointer, :int16, :int16, :int16,
102
+ :uint8, :uint8, :uint8, :uint8 ], :int
103
+
104
+ func :filledCircleColor,
105
+ [ :pointer, :int16, :int16, :int16, :uint32 ], :int
106
+
107
+ func :filledCircleRGBA,
108
+ [ :pointer, :int16, :int16, :int16,
109
+ :uint8, :uint8, :uint8, :uint8 ], :int
110
+
111
+
112
+
113
+ optfunc :arcColor,
114
+ [ :pointer, :int16, :int16, :int16,
115
+ :int16, :int16, :uint32 ], :int
116
+
117
+ optfunc :arcRGBA,
118
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
119
+ :uint8, :uint8, :uint8, :uint8 ], :int
120
+
121
+
122
+
123
+ func :ellipseColor,
124
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
125
+
126
+ func :ellipseRGBA,
127
+ [ :pointer, :int16, :int16, :int16, :int16,
128
+ :uint8, :uint8, :uint8, :uint8 ], :int
129
+
130
+ func :aaellipseColor,
131
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
132
+
133
+ func :aaellipseRGBA,
134
+ [ :pointer, :int16, :int16, :int16, :int16,
135
+ :uint8, :uint8, :uint8, :uint8 ], :int
136
+
137
+ func :filledEllipseColor,
138
+ [ :pointer, :int16, :int16, :int16, :int16, :uint32 ], :int
139
+
140
+ func :filledEllipseRGBA,
141
+ [ :pointer, :int16, :int16, :int16, :int16,
142
+ :uint8, :uint8, :uint8, :uint8 ], :int
143
+
144
+
145
+
146
+ func :pieColor,
147
+ [ :pointer, :int16, :int16, :int16, :int16, :int16, :uint32 ], :int
148
+
149
+ func :pieRGBA,
150
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
151
+ :uint8, :uint8, :uint8, :uint8 ], :int
152
+
153
+ func :filledPieColor,
154
+ [ :pointer, :int16, :int16, :int16, :int16, :int16, :uint32 ], :int
155
+
156
+ func :filledPieRGBA,
157
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
158
+ :uint8, :uint8, :uint8, :uint8 ], :int
159
+
160
+
161
+
162
+ func :trigonColor,
163
+ [ :pointer, :int16, :int16, :int16, :int16,
164
+ :int16, :int16, :uint32 ], :int
165
+
166
+ func :trigonRGBA,
167
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
168
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
169
+
170
+ func :aatrigonColor,
171
+ [ :pointer, :int16, :int16, :int16, :int16,
172
+ :int16, :int16, :uint32 ], :int
173
+
174
+ func :aatrigonRGBA,
175
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
176
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
177
+
178
+ func :filledTrigonColor,
179
+ [ :pointer, :int16, :int16, :int16, :int16,
180
+ :int16, :int16, :uint32 ], :int
181
+
182
+ func :filledTrigonRGBA,
183
+ [ :pointer, :int16, :int16, :int16, :int16, :int16,
184
+ :int16, :uint8, :uint8, :uint8, :uint8 ], :int
185
+
186
+
187
+
188
+ func :polygonColor, [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
189
+
190
+ func :polygonRGBA,
191
+ [ :pointer, :pointer, :pointer, :int,
192
+ :uint8, :uint8, :uint8, :uint8 ], :int
193
+
194
+ func :aapolygonColor,
195
+ [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
196
+
197
+ func :aapolygonRGBA,
198
+ [ :pointer, :pointer, :pointer, :int,
199
+ :uint8, :uint8, :uint8, :uint8 ], :int
200
+
201
+ func :filledPolygonColor,
202
+ [ :pointer, :pointer, :pointer, :int, :uint32 ], :int
203
+
204
+ func :filledPolygonRGBA,
205
+ [ :pointer, :pointer, :pointer, :int,
206
+ :uint8, :uint8, :uint8, :uint8 ], :int
207
+
208
+ optfunc :texturedPolygon,
209
+ [ :pointer, :pointer, :pointer,
210
+ :int, :pointer, :int, :int ], :int
211
+
212
+
213
+ optfunc :filledPolygonColorMT,
214
+ [ :pointer, :pointer, :pointer,
215
+ :int, :uint32, :pointer, :pointer ], :int
216
+
217
+ optfunc :filledPolygonRGBAMT,
218
+ [ :pointer, :pointer, :pointer, :int, :uint8,
219
+ :uint8, :uint8, :uint8, :pointer, :pointer ], :int
220
+
221
+ optfunc :texturedPolygonMT,
222
+ [ :pointer, :pointer, :pointer, :int,
223
+ :pointer, :int, :int, :pointer, :pointer ], :int
224
+
225
+
226
+
227
+ func :bezierColor,
228
+ [ :pointer, :pointer, :pointer, :int, :int, :uint32 ], :int
229
+
230
+ func :bezierRGBA,
231
+ [ :pointer, :pointer, :pointer, :int, :int,
232
+ :uint8, :uint8, :uint8, :uint8 ], :int
233
+
234
+
235
+
236
+ func :characterColor, [ :pointer, :int16, :int16, :char, :uint32 ], :int
237
+
238
+ func :characterRGBA,
239
+ [ :pointer, :int16, :int16, :char,
240
+ :uint8, :uint8, :uint8, :uint8 ], :int
241
+
242
+ func :stringColor, [ :pointer, :int16, :int16, :string, :uint32 ], :int
243
+
244
+ func :stringRGBA,
245
+ [ :pointer, :int16, :int16, :string,
246
+ :uint8, :uint8, :uint8, :uint8 ], :int
247
+
248
+ func :gfxPrimitivesSetFont, [ :pointer, :int, :int ], :void
249
+
250
+ end
251
+ end
@@ -0,0 +1,108 @@
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, :buffer_out, :buffer_out ], :void
58
+
59
+ def self.rotozoomSurfaceSize( width, height, angle, zoom )
60
+ w = FFI::Buffer.new( :int )
61
+ h = FFI::Buffer.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
+ func :rotozoomSurfaceXY,
68
+ [ :pointer, :double, :double, :double, :int ],
69
+ SDL::Surface.typed_pointer
70
+
71
+ func :__rotozoomSurfaceSizeXY, :rotozoomSurfaceSizeXY,
72
+ [ :int, :int, :double, :double, :double,
73
+ :buffer_out, :buffer_out ], :void
74
+
75
+ def self.rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy )
76
+ w = FFI::Buffer.new( :int )
77
+ h = FFI::Buffer.new( :int )
78
+ __rotozoomSurfaceSizeXY( width, height, angle, zoomx, zoomy, w, h )
79
+ return [w.get_int(0), h.get_int(0)]
80
+ end
81
+
82
+
83
+
84
+ func :zoomSurface, [ :pointer, :double, :double, :int ],
85
+ SDL::Surface.typed_pointer
86
+
87
+
88
+ func :__zoomSurfaceSize, :zoomSurfaceSize,
89
+ [ :int, :int, :double, :double, :buffer_out, :buffer_out ], :void
90
+
91
+ def self.zoomSurfaceSize( width, height, zoomx, zoomy )
92
+ w = FFI::Buffer.new( :int )
93
+ h = FFI::Buffer.new( :int )
94
+ __zoomSurfaceSize( width, height, zoomx, zoomy, w, h )
95
+ return [w.get_int(0), h.get_int(0)]
96
+ end
97
+
98
+
99
+
100
+ optfunc :shrinkSurface, [ :pointer, :int, :int ],
101
+ SDL::Surface.typed_pointer
102
+
103
+
104
+ optfunc :rotateSurface90Degrees, [ :pointer, :int ],
105
+ SDL::Surface.typed_pointer
106
+
107
+ end
108
+ 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