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 collapse
- ACCESS_STATIC =
Returns texture access pattern code - changes rarely, not lockable.
INT2NUM(SDL_TEXTUREACCESS_STATIC)
- ACCESS_STREAMING =
Returns texture access pattern code - changes frequently, lockable.
INT2NUM(SDL_TEXTUREACCESS_STREAMING)
- ACCESS_TARGET =
Returns texture access pattern code - can be used as a render target.
INT2NUM(SDL_TEXTUREACCESS_TARGET)
Instance Method Summary collapse
-
#access_pattern ⇒ Integer
Get the access pattern allowed for the texture.
-
#alpha_mod ⇒ Integer
Get an additional alpha value used in render copy operations.
-
#alpha_mod=(alpha) ⇒ void
Set an additional alpha value used in render copy operations.
-
#blend_mode ⇒ Integer
Get the blending mode of the texture.
-
#blend_mode=(mode) ⇒ void
Set the blending model of the texture.
-
#color_mod ⇒ Array(Integer, Integer, Integer)
Get an additional color value used in render copy operations.
-
#color_mod=(rgb) ⇒ void
Set an additional color value used in render copy operations.
-
#debug_info ⇒ Hash<String=>Object>
(GC) debugging information.
-
#destroy ⇒ void
Destroy the texture and deallocate memory.
-
#destroy? ⇒ Boolean
Return true if the texture is destroyed.
-
#format ⇒ SDL2::PixelFormat
Get the format of the texture.
-
#h ⇒ Integer
Get the height of the texture.
-
#inspect ⇒ String
Inspection string.
-
#w ⇒ Integer
Get the width of the texture.
Instance Method Details
#access_pattern ⇒ Integer
Get the access pattern allowed for the texture.
The return value is one of the following:
1982 1983 1984 1985 1986 1987 |
# File 'video.c', line 1982
static VALUE Texture_access_pattern(VALUE self)
{
int access;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, &access, NULL, NULL));
return INT2FIX(access);
}
|
#alpha_mod ⇒ Integer
Get an additional alpha value used in render copy operations.
1905 1906 1907 1908 1909 1910 |
# File 'video.c', line 1905
static VALUE Texture_alpha_mod(VALUE self)
{
Uint8 alpha;
HANDLE_ERROR(SDL_GetTextureAlphaMod(Get_SDL_Texture(self), &alpha));
return INT2FIX(alpha);
}
|
#alpha_mod=(alpha) ⇒ void
1922 1923 1924 1925 1926 |
# File 'video.c', line 1922
static VALUE Texture_set_alpha_mod(VALUE self, VALUE alpha)
{
HANDLE_ERROR(SDL_SetTextureAlphaMod(Get_SDL_Texture(self), NUM2UCHAR(alpha)));
return alpha;
}
|
#blend_mode ⇒ Integer
Get the blending mode of the texture.
1876 1877 1878 1879 1880 1881 |
# File 'video.c', line 1876
static VALUE Texture_blend_mode(VALUE self)
{
SDL_BlendMode mode;
HANDLE_ERROR(SDL_GetTextureBlendMode(Get_SDL_Texture(self), &mode));
return INT2FIX(mode);
}
|
#blend_mode=(mode) ⇒ void
1892 1893 1894 1895 1896 |
# File 'video.c', line 1892
static VALUE Texture_set_blend_mode(VALUE self, VALUE mode)
{
HANDLE_ERROR(SDL_SetTextureBlendMode(Get_SDL_Texture(self), NUM2INT(mode)));
return mode;
}
|
#color_mod ⇒ Array(Integer, Integer, Integer)
Get an additional color value used in render copy operations.
1934 1935 1936 1937 1938 1939 |
# File 'video.c', line 1934
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));
}
|
#color_mod=(rgb) ⇒ void
1949 1950 1951 1952 1953 1954 1955 |
# File 'video.c', line 1949
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;
}
|
#debug_info ⇒ Hash<String=>Object>
Returns (GC) debugging information.
2033 2034 2035 2036 2037 2038 2039 2040 |
# File 'video.c', line 2033
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;
}
|
#destroy ⇒ void
This method returns an undefined value.
Destroy the texture and deallocate memory.
1863 1864 1865 1866 1867 |
# File 'video.c', line 1863
static VALUE Texture_destroy(VALUE self)
{
Texture_destroy_internal(Get_Texture(self));
return Qnil;
}
|
#destroy? ⇒ Boolean
Return true if the texture is destroyed.
#format ⇒ SDL2::PixelFormat
Get the format of the texture.
1962 1963 1964 1965 1966 1967 |
# File 'video.c', line 1962
static VALUE Texture_format(VALUE self)
{
Uint32 format;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), &format, NULL, NULL, NULL));
return PixelFormat_new(format);
}
|
#h ⇒ Integer
Get the height of the texture.
2010 2011 2012 2013 2014 2015 |
# File 'video.c', line 2010
static VALUE Texture_h(VALUE self)
{
int h;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, NULL, NULL, &h));
return INT2FIX(h);
}
|
#inspect ⇒ String
Returns inspection string.
2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 |
# File 'video.c', line 2018
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);
}
|
#w ⇒ Integer
Get the width of the texture.
1996 1997 1998 1999 2000 2001 |
# File 'video.c', line 1996
static VALUE Texture_w(VALUE self)
{
int w;
HANDLE_ERROR(SDL_QueryTexture(Get_SDL_Texture(self), NULL, NULL, &w, NULL));
return INT2FIX(w);
}
|