Class: SDL2::Display::Mode

Inherits:
Object
  • Object
show all
Defined in:
ext/sdl2_ext/video.c,
ext/sdl2_ext/video.c

Overview

This class represents the display mode.

An object of this class has information about color depth, refresh rate, and resolution of a display.

Instance Method Summary collapse

Constructor Details

#initialize(format, w, h, refresh_rate) ⇒ Object

Create a new Display::Mode object.

Parameters:

  • format (SDL2::PixelFormat, Integer)

    pixel format

  • w (Integer)

    the width

  • h (Integer)

    the height

  • refresh_rate (Integer)

    refresh rate



1127
1128
1129
1130
1131
1132
1133
1134
1135
# File 'ext/sdl2_ext/video.c', line 1127

static VALUE DisplayMode_initialize(VALUE self, VALUE format, VALUE w, VALUE h,
                                    VALUE refresh_rate)
{
    SDL_DisplayMode* mode = Get_SDL_DisplayMode(self);
    mode->format = uint32_for_format(format);
    mode->w = NUM2INT(w); mode->h = NUM2INT(h);
    mode->refresh_rate = NUM2INT(refresh_rate);
    return Qnil;
}

Instance Method Details

#formatSDL2::PixelFormat

Returns the pixel format of the display mode.

Returns:



1148
1149
1150
1151
# File 'ext/sdl2_ext/video.c', line 1148

static VALUE DisplayMode_format(VALUE self)
{
    return PixelFormat_new(Get_SDL_DisplayMode(self)->format);
}

#hInteger

Returns the height of the screen of the display mode.

Returns:

  • (Integer)

    the height of the screen of the display mode



1160
1161
1162
1163
# File 'ext/sdl2_ext/video.c', line 1160

static VALUE DisplayMode_h(VALUE self)
{
    return INT2NUM(Get_SDL_DisplayMode(self)->h);
}

#inspectString

Returns inspection string.

Returns:

  • (String)

    inspection string



1138
1139
1140
1141
1142
1143
1144
1145
# File 'ext/sdl2_ext/video.c', line 1138

static VALUE DisplayMode_inspect(VALUE self)
{
    SDL_DisplayMode* mode = Get_SDL_DisplayMode(self);
    return rb_sprintf("<%s: format=%s w=%d h=%d refresh_rate=%d>",
                      rb_obj_classname(self), SDL_GetPixelFormatName(mode->format),
                      mode->w, mode->h, mode->refresh_rate);

}

#refresh_rateInteger

Returns the refresh rate of the display mode.

Returns:

  • (Integer)

    the refresh rate of the display mode



1166
1167
1168
1169
# File 'ext/sdl2_ext/video.c', line 1166

static VALUE DisplayMode_refresh_rate(VALUE self)
{
    return INT2NUM(Get_SDL_DisplayMode(self)->refresh_rate);
}

#wInteger

Returns the width of the screen of the display mode.

Returns:

  • (Integer)

    the width of the screen of the display mode



1154
1155
1156
1157
# File 'ext/sdl2_ext/video.c', line 1154

static VALUE DisplayMode_w(VALUE self)
{
    return INT2NUM(Get_SDL_DisplayMode(self)->w);
}