sdl2_ffi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +2 -2
- data/README.md +9 -1
- data/lib/sdl2.rb +150 -25
- data/lib/sdl2/color.rb +27 -4
- data/lib/sdl2/display.rb +3 -3
- data/lib/sdl2/gem_version.rb +1 -1
- data/lib/sdl2/image.rb +68 -0
- data/lib/sdl2/image/sdl_image_module.rb +8 -0
- data/lib/sdl2/init.rb +8 -8
- data/lib/sdl2/palette.rb +64 -6
- data/lib/sdl2/pixel_format.rb +105 -17
- data/lib/sdl2/pixels.rb +241 -18
- data/lib/sdl2/render.rb +2 -2
- data/lib/sdl2/surface.rb +137 -37
- data/lib/sdl2/ttf.rb +125 -0
- data/lib/sdl2/ttf/sdl_ttf_module.rb +5 -0
- data/lib/sdl2/version.rb +6 -0
- data/lib/sdl2/window.rb +1 -1
- data/test/fixtures/color_bars.jpg +0 -0
- data/test/test_helper.rb +2 -0
- data/test/unit/sdl2/test_hints.rb +3 -3
- data/test/unit/sdl2/test_image.rb +9 -0
- data/test/unit/sdl2/test_palette.rb +26 -0
- data/test/unit/sdl2/test_pixel_format.rb +36 -0
- data/test/unit/sdl2/test_surface.rb +43 -0
- data/test/unit/sdl2/test_ttf.rb +11 -0
- data/test/unit/sdl2/test_window.rb +29 -32
- data/test/unit/test_scratch.rb +19 -0
- data/test/unit/test_sdl2.rb +2 -2
- metadata +18 -2
data/lib/sdl2/render.rb
CHANGED
@@ -50,7 +50,7 @@ module SDL2
|
|
50
50
|
api :SDL_RenderSetClipRect, [Renderer.by_ref, Rect.by_ref], :int
|
51
51
|
api :SDL_RenderGetClipRect, [Renderer.by_ref, Rect.by_ref], :int
|
52
52
|
api :SDL_RenderSetScale, [Renderer.by_ref, :float, :float], :int
|
53
|
-
api :SDL_RenderGetScale, [Renderer.by_ref,
|
53
|
+
api :SDL_RenderGetScale, [Renderer.by_ref, FloatPointer.by_ref, FloatPointer.by_ref], :int
|
54
54
|
api :SDL_SetRenderDrawColor, [Renderer.by_ref, :uint8, :uint8, :uint8, :uint8], :int
|
55
55
|
api :SDL_GetRenderDrawColor, [Renderer.by_ref, UInt8Struct.by_ref,UInt8Struct.by_ref,UInt8Struct.by_ref,UInt8Struct.by_ref], :int
|
56
56
|
api :SDL_SetRenderDrawBlendMode, [Renderer.by_ref, :blend_mode], :int
|
@@ -70,7 +70,7 @@ module SDL2
|
|
70
70
|
api :SDL_RenderPresent, [Renderer.by_ref], :void
|
71
71
|
api :SDL_DestroyTexture, [Texture.by_ref], :void
|
72
72
|
api :SDL_DestroyRenderer, [Renderer.by_ref], :void
|
73
|
-
api :SDL_GL_BindTexture, [Texture.by_ref,
|
73
|
+
api :SDL_GL_BindTexture, [Texture.by_ref, FloatPointer.by_ref, FloatPointer.by_ref], :int
|
74
74
|
api :SDL_GL_UnbindTexture, [Texture.by_ref], :int
|
75
75
|
|
76
76
|
|
data/lib/sdl2/surface.rb
CHANGED
@@ -1,83 +1,183 @@
|
|
1
|
-
require 'sdl2'
|
1
|
+
require 'sdl2/error'
|
2
2
|
require 'sdl2/rwops'
|
3
3
|
require 'sdl2/pixels'
|
4
4
|
require 'sdl2/rect'
|
5
|
+
require 'sdl2/palette'
|
6
|
+
require 'yinum'
|
7
|
+
|
5
8
|
#require 'sdl2/pixel_format'
|
6
9
|
|
7
10
|
module SDL2
|
8
11
|
typedef :uint32, :surface_flags
|
12
|
+
|
13
|
+
#\brief A collection of pixels used in software blitting.
|
14
|
+
#
|
15
|
+
#\note This structure should be treated as read-only, except for \c pixels,
|
16
|
+
# which, if not NULL, contains the raw pixel data for the surface.
|
9
17
|
class Surface < FFI::Struct
|
18
|
+
|
19
|
+
private :[]
|
20
|
+
|
10
21
|
layout :flags, :surface_flags,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
+
:format, PixelFormat.by_ref,
|
23
|
+
:w, :int,
|
24
|
+
:h, :int,
|
25
|
+
:pixels, :pointer,
|
26
|
+
:userdata, :pointer,
|
27
|
+
:locked, :int,
|
28
|
+
:lock_data, :pointer,
|
29
|
+
:clip_rect, Rect,
|
30
|
+
:map, :pointer,
|
31
|
+
:refcount, :int
|
32
|
+
|
33
|
+
[:flags, :format, :w, :h, :pixels, :userdata, :locked, :lock_data, :clip_rect, :map, :refcount].each do |field|
|
34
|
+
define_method field do
|
35
|
+
self[field]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
22
39
|
def self.release(pointer)
|
23
40
|
SDL2.free_surface(pointer)
|
24
41
|
end
|
25
|
-
|
26
|
-
#
|
42
|
+
|
43
|
+
# Allocate and free an RGB surface
|
44
|
+
# If depth is 4 or 8 bits, an empty palette is allocated for the surface.
|
45
|
+
# If depth is > 8 bits, the pixel format is set using the flag masks.
|
46
|
+
# If the function runs out of memory, it will return NULL.
|
47
|
+
def self.create_rgb(flags, width, height, depth, rmask = 0, gmask = 0, bmask = 0, amask = 0)
|
48
|
+
SDL2.create_rgb_surface!(flags, width, height, depth, rmask, gmask, bmask, amask)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.create_rgb_from(pixels, width, height, depth, pitch, rmask, gmask, bmask, amask)
|
52
|
+
SDL2.create_rgb_surface_from!(pixels, width, height, depth, pitch, rmask, gmask, bmask, amask)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.load_bmp_rw(rwops, freesrc = 0)
|
56
|
+
SDL2.load_bmp_rw!(rwops, freesrc)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.load_bmp(file)
|
60
|
+
SDL2.load_bmp!(file)
|
61
|
+
end
|
62
|
+
|
63
|
+
def save_bmp_rw(rwops, freedst = 0)
|
64
|
+
SDL2.save_bmp_rw!(self, rwops, freedst)
|
65
|
+
end
|
66
|
+
|
67
|
+
def save_bmp(file)
|
68
|
+
SDL2.save_bmp!(self, file)
|
69
|
+
end
|
70
|
+
|
71
|
+
def free
|
72
|
+
SDL2.free_surface(self)
|
73
|
+
end
|
74
|
+
|
75
|
+
def set_palette(palette)
|
76
|
+
SDL2.set_surface_palette!(self, palette)
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_palette()
|
80
|
+
#SDL2.get_surface_palette!(self)
|
81
|
+
format.palette
|
82
|
+
end
|
83
|
+
|
84
|
+
alias_method :palette=, :set_palette
|
85
|
+
alias_method :palette, :get_palette
|
86
|
+
|
87
|
+
def lock()
|
88
|
+
SDL2.lock_surface(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
def unlock()
|
92
|
+
SDL2.unlock_surface(self)
|
93
|
+
end
|
94
|
+
|
95
|
+
# Surface Flags
|
27
96
|
SWSURFACE = 0
|
28
97
|
PREALLOC = 0x00000001
|
29
98
|
RLEACCEL = 0x00000002
|
30
99
|
DONTFREE = 0x00000004
|
31
|
-
|
100
|
+
|
32
101
|
# Macro, redefined here for use.
|
33
102
|
def mustlock?
|
34
103
|
self[:flags] & RLEACCEL != 0
|
35
104
|
end
|
36
|
-
|
105
|
+
|
106
|
+
def blit_from(src, src_rect, dst_rect)
|
107
|
+
SDL2.blit!(src, src_rect, self, dst_rect)
|
108
|
+
end
|
109
|
+
|
110
|
+
def blit_to(src_rect, dst, dst_rect)
|
111
|
+
SDL2.blit!(self, src_rect, dst, dst_rect)
|
112
|
+
end
|
113
|
+
|
114
|
+
def set_rle(flag)
|
115
|
+
SDL2.set_surface_rle!(self, flag)
|
116
|
+
end
|
117
|
+
|
118
|
+
alias_method :rle=, :set_rle
|
119
|
+
|
120
|
+
def set_color_key(flag, key)
|
121
|
+
SDL2.set_color_key(self, flag, key)
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_color_key()
|
125
|
+
key_s = UInt32Struct.new
|
126
|
+
SDL2.get_color_key!(self, key_s)
|
127
|
+
return key_s[:value]
|
128
|
+
end
|
37
129
|
end
|
38
|
-
|
130
|
+
|
39
131
|
callback :blit, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
40
|
-
|
41
|
-
|
42
|
-
api :SDL_CreateRGBSurface, [:surface_flags, :int, :int, :int, :uint32, :uint32, :uint32, :uint32], Surface.auto_ptr
|
132
|
+
|
133
|
+
api :SDL_CreateRGBSurface, [:surface_flags, :int, :int, :int, :uint32, :uint32, :uint32, :uint32], Surface.auto_ptr, {error: true, filter: TRUE_WHEN_NOT_NULL}
|
43
134
|
api :SDL_FreeSurface, [Surface.by_ref], :void
|
44
|
-
api :SDL_SetSurfacePalette, [Surface.by_ref, Palette.by_ref], :int
|
135
|
+
api :SDL_SetSurfacePalette, [Surface.by_ref, Palette.by_ref], :int, {error: true}
|
45
136
|
api :SDL_LockSurface, [Surface.by_ref], :int
|
46
137
|
api :SDL_UnlockSurface, [Surface.by_ref], :void
|
47
138
|
api :SDL_LoadBMP_RW, [RWops.by_ref, :int], Surface.auto_ptr
|
139
|
+
|
48
140
|
# Redefine SDL_LoadBMP macro:
|
49
141
|
def self.load_bmp(file)
|
50
142
|
SDL2.load_bmp_rw(RWops.from_file(file, 'rb'), 1)
|
51
143
|
end
|
144
|
+
|
52
145
|
api :SDL_SaveBMP_RW, [Surface.by_ref, RWops.by_ref, :int], :int
|
53
|
-
|
146
|
+
|
54
147
|
def self.save_bmp(file)
|
55
148
|
SDL2.save_bmp_rw(RWops.from_file(file, 'wb'), 1)
|
56
149
|
end
|
57
|
-
|
150
|
+
|
58
151
|
api :SDL_SetSurfaceRLE, [Surface.by_ref, :int], :int
|
59
152
|
api :SDL_SetColorKey, [Surface.by_ref, :int, :uint32], :int
|
60
153
|
api :SDL_GetColorKey, [Surface.by_ref, UInt32Struct.by_ref], :int
|
61
154
|
api :SDL_SetSurfaceColorMod, [Surface.by_ref, :uint8, :uint8, :uint8], :int
|
62
155
|
api :SDL_GetSurfaceColorMod, [Surface.by_ref, UInt8Struct.by_ref,UInt8Struct.by_ref,UInt8Struct.by_ref], :int
|
63
|
-
api :SDL_SetSurfaceAlphaMod, [Surface.by_ref, :uint8], :int
|
64
|
-
api :SDL_GetSurfaceAlphaMod, [Surface.by_ref,UInt8Struct.by_ref], :int
|
65
|
-
api :SDL_SetSurfaceBlendMode, [Surface.by_ref, :blend_mode], :int
|
66
|
-
api :SDL_GetSurfaceBlendMode, [Surface.by_ref, BlendModeStruct.by_ref], :int
|
67
|
-
api :SDL_SetClipRect, [Surface.by_ref, Rect.by_ref], :int
|
68
|
-
api :SDL_GetClipRect, [Surface.by_ref, Rect.by_ref], :int
|
156
|
+
api :SDL_SetSurfaceAlphaMod, [Surface.by_ref, :uint8], :int, {error: true}
|
157
|
+
api :SDL_GetSurfaceAlphaMod, [Surface.by_ref,UInt8Struct.by_ref], :int, {error: true}
|
158
|
+
api :SDL_SetSurfaceBlendMode, [Surface.by_ref, :blend_mode], :int, {error: true}
|
159
|
+
api :SDL_GetSurfaceBlendMode, [Surface.by_ref, BlendModeStruct.by_ref], :int, {error: true}
|
160
|
+
api :SDL_SetClipRect, [Surface.by_ref, Rect.by_ref], :int, {error: true}
|
161
|
+
api :SDL_GetClipRect, [Surface.by_ref, Rect.by_ref], :int, {error: true}
|
69
162
|
api :SDL_ConvertSurface, [Surface.by_ref, PixelFormat.by_ref, :surface_flags], Surface.auto_ptr
|
70
163
|
api :SDL_ConvertSurfaceFormat, [Surface.by_ref, :pixel_format, :surface_flags], Surface.auto_ptr
|
71
|
-
api :SDL_ConvertPixels, [:int, :int, :pixel_format, :pointer, :int, :pixel_format, :pointer, :int], :int
|
72
|
-
api :SDL_FillRect, [Surface.by_ref, Rect.by_ref, :uint32], :int
|
73
|
-
api :SDL_FillRects, [Surface.by_ref, Rect.by_ref, :count, :uint32], :int
|
74
|
-
api :SDL_UpperBlit, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
75
|
-
|
76
|
-
|
164
|
+
api :SDL_ConvertPixels, [:int, :int, :pixel_format, :pointer, :int, :pixel_format, :pointer, :int], :int, {error: true}
|
165
|
+
api :SDL_FillRect, [Surface.by_ref, Rect.by_ref, :uint32], :int, {error: true}
|
166
|
+
api :SDL_FillRects, [Surface.by_ref, Rect.by_ref, :count, :uint32], :int, {error: true}
|
167
|
+
api :SDL_UpperBlit, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int, {error: true}
|
168
|
+
|
169
|
+
def self.blit_surface(src, srcrect, dst, dstrect)
|
170
|
+
upper_blit(src, srcrect, dst, dstrect)
|
171
|
+
end
|
172
|
+
|
77
173
|
api :SDL_LowerBlit, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
78
174
|
api :SDL_SoftStretch, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
79
175
|
api :SDL_UpperBlitScaled, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
80
|
-
|
176
|
+
|
177
|
+
def self.blit_scaled(src, srcrect, dst, dstrect)
|
178
|
+
upper_blit_scaled(src, srcrect, dst, dstrect)
|
179
|
+
end
|
180
|
+
|
81
181
|
api :SDL_LowerBlitScaled, [Surface.by_ref, Rect.by_ref, Surface.by_ref, Rect.by_ref], :int
|
82
|
-
|
182
|
+
|
83
183
|
end
|
data/lib/sdl2/ttf.rb
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'sdl2'
|
2
|
+
require 'sdl2/version'
|
3
|
+
require 'sdl2/ttf/sdl_ttf_module'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
require 'yinum'
|
6
|
+
|
7
|
+
module SDL2
|
8
|
+
|
9
|
+
module TTF
|
10
|
+
|
11
|
+
extend FFI::Library
|
12
|
+
ffi_lib SDL_TTF_MODULE
|
13
|
+
|
14
|
+
def self.api(func_name, args, type)
|
15
|
+
camelCaseName = func_name.to_s.gsub('TTF_','')
|
16
|
+
methodName = ActiveSupport::Inflector.underscore(camelCaseName).to_sym
|
17
|
+
self.attach_function methodName, func_name, args, type
|
18
|
+
return methodName
|
19
|
+
end
|
20
|
+
|
21
|
+
api :TTF_Linked_Version, [], Version.auto_ptr
|
22
|
+
|
23
|
+
UNICODE_BOM_NATIVE = 0xFEFF
|
24
|
+
UNICODE_BOM_SWAPPED = 0xFFFE
|
25
|
+
|
26
|
+
api :TTF_ByteSwappedUNICODE, [:int], :void
|
27
|
+
|
28
|
+
class Font < Struct
|
29
|
+
|
30
|
+
def self.release(pointer)
|
31
|
+
close_font(pointer)
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
api :TTF_Init, [], :int
|
37
|
+
api :TTF_OpenFont, [:string, :int], Font.auto_ptr
|
38
|
+
api :TTF_OpenFontIndex, [:string, :int, :long], Font.auto_ptr
|
39
|
+
api :TTF_OpenFontRW, [RWops.by_ref, :int, :int], Font.auto_ptr
|
40
|
+
api :TTF_OpenFontIndexRW, [RWops.by_ref, :int, :int, :long], Font.auto_ptr
|
41
|
+
|
42
|
+
STYLE = Enum.new(:STYLE, {
|
43
|
+
NORMAL: 0x00,
|
44
|
+
BOLD: 0x01,
|
45
|
+
ITALIC: 0x02,
|
46
|
+
UNDERLINE: 0x04,
|
47
|
+
STRIKETHROUGH: 0x08
|
48
|
+
})
|
49
|
+
|
50
|
+
enum :font_style, STYLE.by_name
|
51
|
+
|
52
|
+
api :TTF_GetFontStyle, [Font.by_ref], :int
|
53
|
+
api :TTF_SetFontStyle, [Font.by_ref, :int], :void
|
54
|
+
api :TTF_GetFontOutline, [Font.by_ref], :int
|
55
|
+
api :TTF_SetFontOutline, [Font.by_ref, :int], :void
|
56
|
+
|
57
|
+
HINTING = Enum.new(:HINTING, {
|
58
|
+
NORMAL: 0,
|
59
|
+
LIGHT: 1,
|
60
|
+
MONO: 2,
|
61
|
+
NONE: 3
|
62
|
+
})
|
63
|
+
enum :hinting, HINTING.by_name
|
64
|
+
|
65
|
+
api :TTF_GetFontHinting, [Font.by_ref], :int
|
66
|
+
api :TTF_SetFontHinting, [Font.by_ref, :int], :void
|
67
|
+
|
68
|
+
api :TTF_FontHeight, [Font.by_ref], :int
|
69
|
+
api :TTF_FontAscent, [Font.by_ref], :int
|
70
|
+
api :TTF_FontDescent, [Font.by_ref], :int
|
71
|
+
api :TTF_FontLineSkip, [Font.by_ref], :int
|
72
|
+
api :TTF_GetFontKerning, [Font.by_ref], :int
|
73
|
+
api :TTF_SetFontKerning, [Font.by_ref], :int
|
74
|
+
api :TTF_FontFaces, [Font.by_ref], :long
|
75
|
+
api :TTF_FontFaceIsFixedWidth, [Font.by_ref], :int
|
76
|
+
api :TTF_FontFaceFamilyName, [Font.by_ref], :string
|
77
|
+
api :TTF_FontFaceStyleName, [Font.by_ref], :string
|
78
|
+
|
79
|
+
api :TTF_GlyphIsProvided, [Font.by_ref, :uint16], :int
|
80
|
+
|
81
|
+
api :TTF_GlyphMetrics, [
|
82
|
+
Font.by_ref,
|
83
|
+
:uint16,
|
84
|
+
IntStruct.by_ref,
|
85
|
+
IntStruct.by_ref,
|
86
|
+
IntStruct.by_ref,
|
87
|
+
IntStruct.by_ref,
|
88
|
+
IntStruct.by_ref
|
89
|
+
], :int
|
90
|
+
|
91
|
+
|
92
|
+
api :TTF_SizeText, [Font.by_ref, :string, IntStruct.by_ref, IntStruct.by_ref], :int
|
93
|
+
api :TTF_SizeUTF8, [Font.by_ref, :string, IntStruct.by_ref, IntStruct.by_ref], :int
|
94
|
+
api :TTF_SizeUNICODE, [Font.by_ref, :string, IntStruct.by_ref, IntStruct.by_ref], :int
|
95
|
+
|
96
|
+
api :TTF_RenderText_Solid, [Font.by_ref, :string, Color], Surface.auto_ptr
|
97
|
+
api :TTF_RenderUTF8_Solid, [Font.by_ref, :string, Color], Surface.auto_ptr
|
98
|
+
api :TTF_RenderUNICODE_Solid, [Font.by_ref, :string, Color], Surface.auto_ptr
|
99
|
+
|
100
|
+
api :TTF_RenderGlyph_Solid, [Font.by_ref, :uint16, Color], Surface.auto_ptr
|
101
|
+
|
102
|
+
api :TTF_RenderText_Shaded, [Font.by_ref, :string, Color, Color], Surface.auto_ptr
|
103
|
+
api :TTF_RenderUTF8_Shaded, [Font.by_ref, :string, Color, Color], Surface.auto_ptr
|
104
|
+
api :TTF_RenderUNICODE_Shaded, [Font.by_ref, :string, Color, Color], Surface.auto_ptr
|
105
|
+
|
106
|
+
api :TTF_RenderGlyph_Shaded, [Font.by_ref, :uint16, Color, Color], Surface.auto_ptr
|
107
|
+
|
108
|
+
api :TTF_RenderText_Blended, [Font.by_ref, :string, Color], Surface.auto_ptr
|
109
|
+
api :TTF_RenderUTF8_Blended, [Font.by_ref, :string, Color], Surface.auto_ptr
|
110
|
+
api :TTF_RenderUNICODE_Blended, [Font.by_ref, :string, Color], Surface.auto_ptr
|
111
|
+
|
112
|
+
api :TTF_RenderText_Blended_Wrapped, [Font.by_ref, :string, Color, :uint32], Surface.auto_ptr
|
113
|
+
api :TTF_RenderUTF8_Blended_Wrapped, [Font.by_ref, :string, Color, :uint32], Surface.auto_ptr
|
114
|
+
api :TTF_RenderUNICODE_Blended_Wrapped, [Font.by_ref, :string, Color, :uint32], Surface.auto_ptr
|
115
|
+
|
116
|
+
api :TTF_RenderGlyph_Blended, [Font.by_ref, :uint16, Color], Surface.auto_ptr
|
117
|
+
|
118
|
+
api :TTF_CloseFont, [Font.by_ref], :void
|
119
|
+
api :TTF_Quit, [], :void
|
120
|
+
api :TTF_WasInit, [], :int
|
121
|
+
api :TTF_GetFontKerningSize, [Font.by_ref, :int, :int], :int
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
data/lib/sdl2/version.rb
CHANGED
@@ -7,6 +7,10 @@ module SDL2
|
|
7
7
|
:minor, :uint8,
|
8
8
|
:patch, :uint8
|
9
9
|
|
10
|
+
def self.release(pointer)
|
11
|
+
pointer.free
|
12
|
+
end
|
13
|
+
|
10
14
|
def major
|
11
15
|
self[:major]
|
12
16
|
end
|
@@ -22,6 +26,8 @@ module SDL2
|
|
22
26
|
def to_s
|
23
27
|
"SDL v#{major}.#{minor}.#{patch}"
|
24
28
|
end
|
29
|
+
|
30
|
+
|
25
31
|
end
|
26
32
|
|
27
33
|
api :SDL_GetRevision, [], :string
|
data/lib/sdl2/window.rb
CHANGED
Binary file
|
data/test/test_helper.rb
CHANGED
@@ -5,9 +5,9 @@ require 'sdl2/hints'
|
|
5
5
|
describe SDL2 do
|
6
6
|
|
7
7
|
it 'has hints' do
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
assert_respond_to SDL2, :clear_hints
|
9
|
+
assert_respond_to SDL2, :get_hint
|
10
|
+
assert_respond_to SDL2, :set_hint
|
11
11
|
|
12
12
|
assert_equal 'constant', defined?(SDL2::HINT_FRAMEBUFFER_ACCELERATION)
|
13
13
|
assert_equal 'constant', defined?(SDL2::HINT_IDLE_TIMER_DISABLED)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../../test_helper'
|
2
|
+
|
3
|
+
require 'sdl2/pixels' #defines SDL_Palette
|
4
|
+
|
5
|
+
describe SDL2::Palette do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@palette = SDL2::Palette.create(32)
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
SDL2::Palette.release(@palette)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'can be created' do
|
16
|
+
refute @palette.null?
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'can set colors from a ruby array of arrays' do
|
20
|
+
@palette.set_colors([[255,0,0],[0,255,0],[0,0,255]])
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
end
|