class SDL2::Texture
Public Class Methods
create(renderer, format, access, w, h)
click to toggle source
Constructs a texture within a renderer
# File lib/sdl2/texture.rb, line 33 def self.create(renderer, format, access, w, h) SDL2.create_texture!(renderer, format, access, w, h) end
release(pointer)
click to toggle source
Ensures the texture is properly disposed of
# File lib/sdl2/texture.rb, line 28 def self.release(pointer) SDL2.destroy_texture(pointer) end
Public Instance Methods
alpha_mod()
click to toggle source
Returns the alpha modulation (0~255)
# File lib/sdl2/texture.rb, line 43 def alpha_mod alpha = SDL2::TypedPointer::UInt8.new SDL2.get_texture_alpha_mod!(self, alpha) alpha.value end
alpha_mod=(uInt8)
click to toggle source
Sets the alpha modulation (0~255)
# File lib/sdl2/texture.rb, line 50 def alpha_mod=(uInt8) SDL2.set_texture_alpha_mod!(self, uInt8) end
blend_mode()
click to toggle source
Returns the blend mode
NOTE: This will be a symbol of the constant value.
# File lib/sdl2/texture.rb, line 56 def blend_mode blend_mode = SDL2::TypedPointer::BlendMode.new SDL2.get_texture_blend_mode!(self, blend_mode) blend_mode.value end
blend_mode=(blend_mode)
click to toggle source
Accepts a new blend mode value. NOTE: Accepts symbol or SDL2::BLENDMODE
constant values.
# File lib/sdl2/texture.rb, line 64 def blend_mode=(blend_mode) SDL2.set_texture_blend_mode!(self, blend_mode) end
color_mod()
click to toggle source
Returns the color modulation, an array of 3 integers (0~255)
# File lib/sdl2/texture.rb, line 69 def color_mod colors = 3.times.map{SDL2::TypedPointer::UInt8.new} SDL2.get_texture_color_mod!(self, *colors) colors.map(&:value) end
color_mod=(colors)
click to toggle source
Sets the color modulation, expects an array of 3 integers (0~255)
# File lib/sdl2/texture.rb, line 76 def color_mod=(colors) raise "At least 3 for RGB, not #{colors.count}" if colors.count < 3 SDL2.set_texture_color_mod!(self, *colors.first(3)) colors end
destroy()
click to toggle source
Destroy this texture
# File lib/sdl2/texture.rb, line 38 def destroy SDL2.destroy_texture(self) end
lock(rect = nil)
click to toggle source
Lock a portion (or all) of a texture for write access Returns: [pointer, pitch]
pointer - An FFI::Pointer to the locked pixels pitch - An integer pitch value
# File lib/sdl2/texture.rb, line 86 def lock(rect = nil) pointer = SDL2::TypedPointer::Pointer.new pitch = SDL2::TypedPointer::Int.new SDL2.lock_texture!(self, rect, pointer, pitch) [pointer.value, pitch.value] end
query()
click to toggle source
Query the texture about itself: Returns: [format, access, w, h]
format - An SDL2::PIXELFORMAT value access - AN SDL2::TEXTUREACCESS value w - an integer representing the width h - an integer representing the height
# File lib/sdl2/texture.rb, line 104 def query() query = [ SDL2::TypedPointer::PixelFormat.new, SDL2::TypedPointer::TextureAccess.new, SDL2::TypedPointer::Int.new, SDL2::TypedPointer::Int.new ] SDL2.query_texture!(self, *query) query.map(&:value) end
unlock()
click to toggle source
Unlock
# File lib/sdl2/texture.rb, line 94 def unlock() SDL2.unlock_texture(self) end