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

- (Object) initialze(format, w, h, refresh_rate)

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



1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'video.c', line 1097

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

- (SDL2::PixelFormat) format

Returns the pixel format of the display mode

Returns:



1118
1119
1120
1121
# File 'video.c', line 1118

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

- (Integer) h

Returns the height of the screen of the display mode

Returns:

  • (Integer)

    the height of the screen of the display mode



1130
1131
1132
1133
# File 'video.c', line 1130

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

- (String) inspect

Returns inspection string

Returns:

  • (String)

    inspection string



1108
1109
1110
1111
1112
1113
1114
1115
# File 'video.c', line 1108

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);
                      
}

- (Integer) refresh_rate

Returns the refresh rate of the display mode

Returns:

  • (Integer)

    the refresh rate of the display mode



1136
1137
1138
1139
# File 'video.c', line 1136

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

- (Integer) w

Returns the width of the screen of the display mode

Returns:

  • (Integer)

    the width of the screen of the display mode



1124
1125
1126
1127
# File 'video.c', line 1124

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