Class: SDL2::Display
- Inherits:
-
Object
- Object
- SDL2::Display
- Defined in:
- video.c,
video.c
Overview
This class represents displays, screens, or monitors.
This means that if you use dual screen, Display.displays returns two displays.
This class handles color depth, resolution, and refresh rate of displays.
Defined Under Namespace
Classes: Mode
Instance Attribute Summary collapse
-
#index ⇒ Integer
readonly
The index of the display, 0 origin.
-
#name ⇒ Stirng
readonly
The name of the display.
Class Method Summary collapse
-
.displays ⇒ Array<SDL2::Display>
Get all connected displays.
Instance Method Summary collapse
-
#bounds ⇒ Rect
Get the desktop area represented by the display, with the primary display located at (0, 0).
-
#closest_mode(mode) ⇒ SDL2::Display::Mode
Get the available display mode closest match to mode.
-
#current_mode ⇒ SDL2::Display::Mode
Get the current display mode.
-
#desktop_mode ⇒ SDL2::Display::Mode
Get the desktop display mode.
-
#modes ⇒ Array<SDL2::Display::Mode>
Get available display modes of the display.
Instance Attribute Details
#index ⇒ Integer (readonly)
The index of the display, 0 origin
#name ⇒ Stirng (readonly)
The name of the display
Class Method Details
.displays ⇒ Array<SDL2::Display>
Get all connected displays.
987 988 989 990 991 992 993 994 995 |
# File 'video.c', line 987
static VALUE Display_s_displays(VALUE self)
{
int i;
int num_displays = HANDLE_ERROR(SDL_GetNumVideoDisplays());
VALUE displays = rb_ary_new2(num_displays);
for (i=0; i<num_displays; ++i)
rb_ary_push(displays, Display_new(i));
return displays;
}
|
Instance Method Details
#bounds ⇒ Rect
Get the desktop area represented by the display, with the primary display located at (0, 0).
1077 1078 1079 1080 1081 1082 |
# File 'video.c', line 1077
static VALUE Display_bounds(VALUE self)
{
VALUE rect = rb_obj_alloc(cRect);
HANDLE_ERROR(SDL_GetDisplayBounds(Display_index_int(self), Get_SDL_Rect(rect)));
return rect;
}
|
#closest_mode(mode) ⇒ SDL2::Display::Mode
1062 1063 1064 1065 1066 1067 1068 1069 |
# File 'video.c', line 1062
static VALUE Display_closest_mode(VALUE self, VALUE mode)
{
SDL_DisplayMode closest;
if (!SDL_GetClosestDisplayMode(Display_index_int(self), Get_SDL_DisplayMode(mode),
&closest))
SDL_ERROR();
return DisplayMode_new(&closest);
}
|
#current_mode ⇒ SDL2::Display::Mode
Get the current display mode.
1029 1030 1031 1032 1033 1034 |
# File 'video.c', line 1029
static VALUE Display_current_mode(VALUE self)
{
SDL_DisplayMode mode;
HANDLE_ERROR(SDL_GetCurrentDisplayMode(Display_index_int(self), &mode));
return DisplayMode_new(&mode);
}
|
#desktop_mode ⇒ SDL2::Display::Mode
Get the desktop display mode.
Normally, the return value of this method is same as #current_mode. However, when you use fullscreen and chagne the resolution, this method returns the previous native display mode, and not the current mode.
1047 1048 1049 1050 1051 1052 |
# File 'video.c', line 1047
static VALUE Display_desktop_mode(VALUE self)
{
SDL_DisplayMode mode;
HANDLE_ERROR(SDL_GetDesktopDisplayMode(Display_index_int(self), &mode));
return DisplayMode_new(&mode);
}
|
#modes ⇒ Array<SDL2::Display::Mode>
Get available display modes of the display.
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
# File 'video.c', line 1008
static VALUE Display_modes(VALUE self)
{
int i;
int index = Display_index_int(self);
int num_modes = SDL_GetNumDisplayModes(index);
VALUE modes = rb_ary_new2(num_modes);
for (i=0; i<num_modes; ++i) {
SDL_DisplayMode mode;
HANDLE_ERROR(SDL_GetDisplayMode(index, i, &mode));
rb_ary_push(modes, DisplayMode_new(&mode));
}
return modes;
}
|