Class: SDL::Surface
- Inherits:
-
Object
- Object
- SDL::Surface
- Defined in:
- ext/sdl/sdl.c
Direct Known Subclasses
Class Method Summary collapse
-
.load(path) ⇒ Object
// SDL::Surface methods:.
Instance Method Summary collapse
- #[](x, y) ⇒ Object
- #format ⇒ Object
- #h ⇒ Object
-
#make_collision_map ⇒ Object
TODO: reimplement and jettison SGE.
-
#transform(angle, xscale, yscale, flags) ⇒ Object
TODO: maybe remove? I dunno…
- #w ⇒ Object
Class Method Details
.load(path) ⇒ Object
// SDL::Surface methods:
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
# File 'ext/sdl/sdl.c', line 479
static VALUE Surface_s_load(VALUE klass, VALUE path) {
UNUSED(klass);
SDL_Surface *surface;
ExportStringValue(path);
surface = IMG_Load(RSTRING_PTR(path));
if (!surface)
rb_raise(eSDLError, "Couldn't load file %s : %s",
RSTRING_PTR(path),
SDL_GetError());
return TypedData_Wrap_Struct(cSurface, &_Surface_type, surface);
}
|
Instance Method Details
#[](x, y) ⇒ Object
806 807 808 809 |
# File 'ext/sdl/sdl.c', line 806
static VALUE Surface_index(VALUE self, VALUE x, VALUE y) {
rb_raise(eSDLError, "Reading the canvas isn't currently supported");
return Qnil;
}
|
#format ⇒ Object
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'ext/sdl/sdl.c', line 755
static VALUE Surface_format(VALUE self) {
DEFINE_SELF(Surface, surface, self);
SDL_PixelFormat* format;
SDL_Palette* palette;
SDL_Palette* src = surface->format->palette;
// TODO: remove this or drop down to SDL_AllocFormat only
if (src) {
palette = ALLOC(SDL_Palette);
palette->ncolors = src->ncolors;
palette->colors = ALLOC_N(SDL_Color, (size_t)src->ncolors);
MEMCPY(palette->colors, src->colors, SDL_Color, (size_t)src->ncolors);
} else {
palette = NULL;
}
VALUE ret = TypedData_Make_Struct(cPixelFormat, SDL_PixelFormat, &_PixelFormat_type, format);
*format = *(surface->format);
format->palette = palette;
return ret;
}
|
#h ⇒ Object
800 801 802 803 804 |
# File 'ext/sdl/sdl.c', line 800
static VALUE Surface_h(VALUE self) {
DEFINE_SELF(Surface, surface, self);
return INT2NUM(surface->h);
}
|
#make_collision_map ⇒ Object
TODO: reimplement and jettison SGE
838 839 840 841 842 843 844 845 846 |
# File 'ext/sdl/sdl.c', line 838
static VALUE Surface_make_collision_map(VALUE self) {
DEFINE_SELF(Surface, surface, self);
sge_cdata * cdata = sge_make_cmap(surface);
if (!cdata)
FAILURE("Surface#make_collision_map");
return TypedData_Wrap_Struct(cCollisionMap, &_CollisionMap_type, cdata);
}
|
#transform(angle, xscale, yscale, flags) ⇒ Object
TODO: maybe remove? I dunno… could be nice for pre-rendering?
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
# File 'ext/sdl/sdl.c', line 855
static VALUE Surface_transform(VALUE self, VALUE angle,
VALUE xscale, VALUE yscale,
VALUE flags) {
DEFINE_SELF(Surface, surface, self);
SDL_Surface *result = rotozoomSurfaceXY(surface,
NUM2FLT(angle),
NUM2FLT(xscale),
NUM2FLT(yscale),
SMOOTHING_ON);
if (!result)
FAILURE("Surface#transform");
return TypedData_Wrap_Struct(cSurface, &_Surface_type, result);
}
|
#w ⇒ Object
848 849 850 851 852 |
# File 'ext/sdl/sdl.c', line 848
static VALUE Surface_w(VALUE self) {
DEFINE_SELF(Surface, surface, self);
return INT2NUM(surface->w);
}
|