Class: SDL2::Display
- Inherits:
-
Object
- Object
- SDL2::Display
- Defined in:
- ext/sdl2_ext/video.c,
ext/sdl2_ext/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.
1002 1003 1004 1005 1006 1007 1008 1009 1010 |
# File 'ext/sdl2_ext/video.c', line 1002
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).
1092 1093 1094 1095 1096 1097 |
# File 'ext/sdl2_ext/video.c', line 1092
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
1077 1078 1079 1080 1081 1082 1083 1084 |
# File 'ext/sdl2_ext/video.c', line 1077
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.
1044 1045 1046 1047 1048 1049 |
# File 'ext/sdl2_ext/video.c', line 1044
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.
1062 1063 1064 1065 1066 1067 |
# File 'ext/sdl2_ext/video.c', line 1062
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.
1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 |
# File 'ext/sdl2_ext/video.c', line 1023
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;
}
|