Class: SDL2::Display::Mode

Inherits:
Object
  • Object
show all
Defined in:
video.c,
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

#initialze(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



1112
1113
1114
1115
1116
1117
1118
1119
1120
# File 'video.c', line 1112

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:



1133
1134
1135
1136
# File 'video.c', line 1133

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



1145
1146
1147
1148
# File 'video.c', line 1145

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

#inspectString

Returns inspection string

Returns:

  • (String)

    inspection string



1123
1124
1125
1126
1127
1128
1129
1130
# File 'video.c', line 1123

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



1151
1152
1153
1154
# File 'video.c', line 1151

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



1139
1140
1141
1142
# File 'video.c', line 1139

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