Class: SDL2::Texture
- Inherits:
-
Object
- Object
- SDL2::Texture
- Defined in:
- video.c,
video.c
Overview
This class represents the texture associated with a renderer.
Constant Summary
- ACCESS_STATIC =
texture access pattern - changes rarely, not lockable
INT2NUM(SDL_TEXTUREACCESS_STATIC)
- ACCESS_STREAMING =
texture access pattern - changes frequently, lockable
INT2NUM(SDL_TEXTUREACCESS_STREAMING)
- ACCESS_TARGET =
texture access pattern - can be used as a render target
INT2NUM(SDL_TEXTUREACCESS_TARGET)
Instance Method Summary (collapse)
-
- (Integer) access_pattern
Get the access pattern allowed for the texture.
-
- (Integer) alpha_mod
Get an additional alpha value used in render copy operations.
-
- (alpha) alpha_mod=(alpha)
Set an additional alpha value used in render copy operations.
-
- (Integer) blend_mode
Get the blending mode of the texture.
-
- (mode) blend_mode=(mode)
Set the blending model of the texture.
-
- ([Integer, Integer, Integer]) color_mod
Get an additional color value used in render copy operations.
-
- (rgb) color_mod=(rgb)
Set an additional color value used in render copy operations.
-
- (Hash<String=>Object>) debug_info
(GC) debugging information.
-
- (Object) destroy
Destroy the texture and deallocate memory.
-
- (Boolean) destroy?
Return true if the texture is destroyed.
-
- (SDL2::PixelFormat) format
Get the format of the texture.
-
- (Integer) h
Get the height of the texture.
-
- (String) inspect
Inspection string.
-
- (Integer) w
Get the width of the texture.
Instance Method Details
- (Integer) access_pattern
Get the access pattern allowed for the texture.
The return value is one of the following:
1781 1782 1783 1784 1785 1786 |
# File 'video.c', line 1781
static VALUE Texture_access_pattern(VALUE self)
{
int access;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, &access, NULL, NULL));
return INT2FIX(access);
}
|
- (Integer) alpha_mod
Get an additional alpha value used in render copy operations.
1704 1705 1706 1707 1708 1709 |
# File 'video.c', line 1704
static VALUE Texture_alpha_mod(VALUE self)
{
Uint8 alpha;
HANDLE_ERROR(SDL_GetTextureAlphaMod(Get_SDL_Texture(self), &alpha));
return INT2FIX(alpha);
}
|
- (alpha) alpha_mod=(alpha)
1721 1722 1723 1724 1725 |
# File 'video.c', line 1721
static VALUE Texture_set_alpha_mod(VALUE self, VALUE alpha)
{
HANDLE_ERROR(SDL_SetTextureAlphaMod(Get_SDL_Texture(self), NUM2UCHAR(alpha)));
return alpha;
}
|
- (Integer) blend_mode
Get the blending mode of the texture.
1675 1676 1677 1678 1679 1680 |
# File 'video.c', line 1675
static VALUE Texture_blend_mode(VALUE self)
{
SDL_BlendMode mode;
HANDLE_ERROR(SDL_GetTextureBlendMode(Get_SDL_Texture(self), &mode));
return INT2FIX(mode);
}
|
- (mode) blend_mode=(mode)
1691 1692 1693 1694 1695 |
# File 'video.c', line 1691
static VALUE Texture_set_blend_mode(VALUE self, VALUE mode)
{
HANDLE_ERROR(SDL_SetTextureBlendMode(Get_SDL_Texture(self), NUM2INT(mode)));
return mode;
}
|
- ([Integer, Integer, Integer]) color_mod
Get an additional color value used in render copy operations.
1733 1734 1735 1736 1737 1738 |
# File 'video.c', line 1733
static VALUE Texture_color_mod(VALUE self)
{
Uint8 r, g, b;
HANDLE_ERROR(SDL_GetTextureColorMod(Get_SDL_Texture(self), &r, &g, &b));
return rb_ary_new3(3, INT2FIX(r), INT2FIX(g), INT2FIX(b));
}
|
- (rgb) color_mod=(rgb)
1748 1749 1750 1751 1752 1753 1754 |
# File 'video.c', line 1748
static VALUE Texture_set_color_mod(VALUE self, VALUE rgb)
{
SDL_Color color = Array_to_SDL_Color(rgb);
HANDLE_ERROR(SDL_SetTextureColorMod(Get_SDL_Texture(self),
color.r, color.g, color.b));
return rgb;
}
|
- (Hash<String=>Object>) debug_info
Returns (GC) debugging information
1832 1833 1834 1835 1836 1837 1838 1839 |
# File 'video.c', line 1832
static VALUE Texture_debug_info(VALUE self)
{
Texture* t = Get_Texture(self);
VALUE info = rb_hash_new();
rb_hash_aset(info, rb_str_new2("destroy?"), INT2BOOL(t->texture == NULL));
rb_hash_aset(info, rb_str_new2("refcount"), INT2NUM(t->refcount));
return info;
}
|
- (Object) destroy
Destroy the texture and deallocate memory.
1662 1663 1664 1665 1666 |
# File 'video.c', line 1662
static VALUE Texture_destroy(VALUE self)
{
Texture_destroy_internal(Get_Texture(self));
return Qnil;
}
|
- (Boolean) destroy?
Return true if the texture is destroyed.
- (SDL2::PixelFormat) format
Get the format of the texture.
1761 1762 1763 1764 1765 1766 |
# File 'video.c', line 1761
static VALUE Texture_format(VALUE self)
{
Uint32 format;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), &format, NULL, NULL, NULL));
return PixelFormat_new(format);
}
|
- (Integer) h
Get the height of the texture.
1809 1810 1811 1812 1813 1814 |
# File 'video.c', line 1809
static VALUE Texture_h(VALUE self)
{
int h;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, NULL, NULL, &h));
return INT2FIX(h);
}
|
- (String) inspect
Returns inspection string
1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 |
# File 'video.c', line 1817
static VALUE Texture_inspect(VALUE self)
{
Texture* t = Get_Texture(self);
Uint32 format;
int access, w, h;
if (!t->texture)
return rb_sprintf("<%s: (destroyed)>", rb_obj_classname(self));
HANDLE_ERROR(SDL_QueryTexture(t->texture, &format, &access, &w, &h));
return rb_sprintf("<%s:%p format=%s access=%d w=%d h=%d>",
rb_obj_classname(self), (void*)self, SDL_GetPixelFormatName(format),
access, w, h);
}
|
- (Integer) w
Get the width of the texture.
1795 1796 1797 1798 1799 1800 |
# File 'video.c', line 1795
static VALUE Texture_w(VALUE self)
{
int w;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, NULL, &w, NULL));
return INT2FIX(w);
}
|