We cannot maintain an updated list of displays, change to 'System.getDisplay' instead
This commit is contained in:
@@ -20,7 +20,6 @@ import lime.ui.Window;
|
|||||||
@:access(lime._backend.native.NativeRenderer)
|
@:access(lime._backend.native.NativeRenderer)
|
||||||
@:access(lime.app.Application)
|
@:access(lime.app.Application)
|
||||||
@:access(lime.graphics.Renderer)
|
@:access(lime.graphics.Renderer)
|
||||||
@:access(lime.system.Display)
|
|
||||||
@:access(lime.ui.Gamepad)
|
@:access(lime.ui.Gamepad)
|
||||||
@:access(lime.ui.Window)
|
@:access(lime.ui.Window)
|
||||||
|
|
||||||
@@ -59,33 +58,6 @@ class NativeApplication {
|
|||||||
|
|
||||||
handle = lime_application_create (null);
|
handle = lime_application_create (null);
|
||||||
|
|
||||||
#if !lime_console
|
|
||||||
|
|
||||||
// TODO: Evolve this more
|
|
||||||
|
|
||||||
var displays:Array<Dynamic> = lime_display_get_details ();
|
|
||||||
|
|
||||||
for (displayInfo in displays) {
|
|
||||||
|
|
||||||
var display = new Display ();
|
|
||||||
display.name = displayInfo.name;
|
|
||||||
display.supportedModes = [];
|
|
||||||
display.bounds = new Rectangle (displayInfo.bounds.x, displayInfo.bounds.y, displayInfo.bounds.width, displayInfo.bounds.height);
|
|
||||||
|
|
||||||
for (mode in cast (displayInfo.supportedModes, Array<Dynamic>)) {
|
|
||||||
|
|
||||||
var displayMode = new DisplayMode (mode.width, mode.height, mode.refreshRate, mode.pixelFormat);
|
|
||||||
display.supportedModes.push (displayMode);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
display.currentMode = display.supportedModes[displayInfo.currentMode];
|
|
||||||
Display.devices.push (display);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#end
|
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
|
|
||||||
setFrameRate (config.fps);
|
setFrameRate (config.fps);
|
||||||
@@ -475,7 +447,6 @@ class NativeApplication {
|
|||||||
private static var lime_application_set_frame_rate = System.load ("lime", "lime_application_set_frame_rate", 2);
|
private static var lime_application_set_frame_rate = System.load ("lime", "lime_application_set_frame_rate", 2);
|
||||||
private static var lime_application_update = System.load ("lime", "lime_application_update", 1);
|
private static var lime_application_update = System.load ("lime", "lime_application_update", 1);
|
||||||
private static var lime_application_quit = System.load ("lime", "lime_application_quit", 1);
|
private static var lime_application_quit = System.load ("lime", "lime_application_quit", 1);
|
||||||
private static var lime_display_get_details = System.load ("lime", "lime_display_get_details", 0);
|
|
||||||
private static var lime_gamepad_event_manager_register = System.load ("lime", "lime_gamepad_event_manager_register", 2);
|
private static var lime_gamepad_event_manager_register = System.load ("lime", "lime_gamepad_event_manager_register", 2);
|
||||||
private static var lime_key_event_manager_register = System.load ("lime", "lime_key_event_manager_register", 2);
|
private static var lime_key_event_manager_register = System.load ("lime", "lime_key_event_manager_register", 2);
|
||||||
private static var lime_mouse_event_manager_register = System.load ("lime", "lime_mouse_event_manager_register", 2);
|
private static var lime_mouse_event_manager_register = System.load ("lime", "lime_mouse_event_manager_register", 2);
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ import lime.math.Rectangle;
|
|||||||
class Display {
|
class Display {
|
||||||
|
|
||||||
|
|
||||||
public static var devices = new Array<Display> ();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The desktop area represented by this display, with the upper-leftmost display at 0,0
|
* The desktop area represented by this display, with the upper-leftmost display at 0,0
|
||||||
**/
|
**/
|
||||||
@@ -19,6 +17,8 @@ class Display {
|
|||||||
**/
|
**/
|
||||||
public var currentMode (default, null):DisplayMode;
|
public var currentMode (default, null):DisplayMode;
|
||||||
|
|
||||||
|
public var id (default, null):Int;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the device, such as "Samsung SyncMaster P2350", "iPhone 6", "Occulus Rift DK2", etc.
|
* The name of the device, such as "Samsung SyncMaster P2350", "iPhone 6", "Occulus Rift DK2", etc.
|
||||||
**/
|
**/
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class DisplayMode {
|
|||||||
public var width (default, null):Int;
|
public var width (default, null):Int;
|
||||||
|
|
||||||
|
|
||||||
public function new (width:Int, height:Int, refreshRate:Int, pixelFormat:PixelFormat) {
|
private function new (width:Int, height:Int, refreshRate:Int, pixelFormat:PixelFormat) {
|
||||||
|
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package lime.system;
|
package lime.system;
|
||||||
|
|
||||||
|
|
||||||
|
import lime.math.Rectangle;
|
||||||
|
|
||||||
#if !macro
|
#if !macro
|
||||||
import lime.app.Application;
|
import lime.app.Application;
|
||||||
#end
|
#end
|
||||||
@@ -22,6 +24,9 @@ import js.Browser;
|
|||||||
import sys.io.Process;
|
import sys.io.Process;
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
@:access(lime.system.Display)
|
||||||
|
@:access(lime.system.DisplayMode)
|
||||||
|
|
||||||
|
|
||||||
class System {
|
class System {
|
||||||
|
|
||||||
@@ -32,6 +37,7 @@ class System {
|
|||||||
public static var disableCFFI:Bool;
|
public static var disableCFFI:Bool;
|
||||||
public static var documentsDirectory (get, null):String;
|
public static var documentsDirectory (get, null):String;
|
||||||
public static var fontsDirectory (get, null):String;
|
public static var fontsDirectory (get, null):String;
|
||||||
|
public static var numDisplays (get, null):Int;
|
||||||
public static var userDirectory (get, null):String;
|
public static var userDirectory (get, null):String;
|
||||||
|
|
||||||
|
|
||||||
@@ -162,6 +168,39 @@ class System {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static function getDisplay (id:Int):Display {
|
||||||
|
|
||||||
|
#if (cpp || neko || nodejs)
|
||||||
|
var displayInfo = lime_system_get_display (id);
|
||||||
|
|
||||||
|
if (displayInfo != null) {
|
||||||
|
|
||||||
|
var display = new Display ();
|
||||||
|
display.id = id;
|
||||||
|
display.name = displayInfo.name;
|
||||||
|
display.bounds = new Rectangle (displayInfo.bounds.x, displayInfo.bounds.y, displayInfo.bounds.width, displayInfo.bounds.height);
|
||||||
|
display.supportedModes = [];
|
||||||
|
|
||||||
|
var displayMode;
|
||||||
|
|
||||||
|
for (mode in cast (displayInfo.supportedModes, Array<Dynamic>)) {
|
||||||
|
|
||||||
|
displayMode = new DisplayMode (mode.width, mode.height, mode.refreshRate, mode.pixelFormat);
|
||||||
|
display.supportedModes.push (displayMode);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
display.currentMode = display.supportedModes[displayInfo.currentMode];
|
||||||
|
return display;
|
||||||
|
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getTimer ():Int {
|
public static function getTimer ():Int {
|
||||||
|
|
||||||
#if flash
|
#if flash
|
||||||
@@ -531,6 +570,17 @@ class System {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static function get_numDisplays ():Int {
|
||||||
|
|
||||||
|
#if (cpp || neko || nodejs)
|
||||||
|
return lime_system_get_num_displays ();
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#end
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private static function get_userDirectory ():String {
|
private static function get_userDirectory ():String {
|
||||||
|
|
||||||
#if (cpp || neko || nodejs)
|
#if (cpp || neko || nodejs)
|
||||||
@@ -551,6 +601,8 @@ class System {
|
|||||||
|
|
||||||
#if (cpp || neko || nodejs)
|
#if (cpp || neko || nodejs)
|
||||||
private static var lime_system_get_directory = System.load ("lime", "lime_system_get_directory", 3);
|
private static var lime_system_get_directory = System.load ("lime", "lime_system_get_directory", 3);
|
||||||
|
private static var lime_system_get_display = System.load ("lime", "lime_system_get_display", 1);
|
||||||
|
private static var lime_system_get_num_displays = System.load ("lime", "lime_system_get_num_displays", 0);
|
||||||
private static var lime_system_get_timer = System.load ("lime", "lime_system_get_timer", 0);
|
private static var lime_system_get_timer = System.load ("lime", "lime_system_get_timer", 0);
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,6 @@
|
|||||||
<file name="src/backend/sdl/SDLWindow.cpp" />
|
<file name="src/backend/sdl/SDLWindow.cpp" />
|
||||||
<file name="src/backend/sdl/SDLRenderer.cpp" />
|
<file name="src/backend/sdl/SDLRenderer.cpp" />
|
||||||
<file name="src/backend/sdl/SDLGamepad.cpp" />
|
<file name="src/backend/sdl/SDLGamepad.cpp" />
|
||||||
<file name="src/backend/sdl/SDLDisplay.cpp" />
|
|
||||||
<file name="src/backend/sdl/SDLMouse.cpp" />
|
<file name="src/backend/sdl/SDLMouse.cpp" />
|
||||||
<file name="src/backend/sdl/SDLSystem.cpp" />
|
<file name="src/backend/sdl/SDLSystem.cpp" />
|
||||||
<file name="src/backend/sdl/SDLJNI.cpp" />
|
<file name="src/backend/sdl/SDLJNI.cpp" />
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
#ifndef LIME_SYSTEM_DISPLAY_H
|
|
||||||
#define LIME_SYSTEM_DISPLAY_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <hx/CFFI.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace lime {
|
|
||||||
|
|
||||||
|
|
||||||
class Display {
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
static value GetDetails ();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LIME_SYSTEM_SYSTEM_H
|
#ifndef LIME_SYSTEM_SYSTEM_H
|
||||||
#define LIME_SYSTEM_SYSTEM_H
|
#define LIME_SYSTEM_SYSTEM_H
|
||||||
|
|
||||||
|
#include <hx/CFFI.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ namespace lime {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
static const char* GetDirectory (SystemDirectory type, const char* company, const char* title);
|
static const char* GetDirectory (SystemDirectory type, const char* company, const char* title);
|
||||||
|
static value GetDisplay (int id);
|
||||||
|
static int GetNumDisplays ();
|
||||||
static double GetTimer ();
|
static double GetTimer ();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,6 @@
|
|||||||
#include <graphics/ImageBuffer.h>
|
#include <graphics/ImageBuffer.h>
|
||||||
#include <graphics/Renderer.h>
|
#include <graphics/Renderer.h>
|
||||||
#include <graphics/RenderEvent.h>
|
#include <graphics/RenderEvent.h>
|
||||||
#include <system/Display.h>
|
|
||||||
#include <system/System.h>
|
#include <system/System.h>
|
||||||
#include <text/Font.h>
|
#include <text/Font.h>
|
||||||
#include <text/TextLayout.h>
|
#include <text/TextLayout.h>
|
||||||
@@ -161,13 +160,6 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
value lime_display_get_details () {
|
|
||||||
|
|
||||||
return Display::GetDetails ();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void lime_font_destroy (value handle) {
|
void lime_font_destroy (value handle) {
|
||||||
|
|
||||||
Font *font = (Font*)(intptr_t)val_float (handle);
|
Font *font = (Font*)(intptr_t)val_float (handle);
|
||||||
@@ -922,6 +914,20 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
value lime_system_get_display (value id) {
|
||||||
|
|
||||||
|
return System::GetDisplay (val_int (id));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
value lime_system_get_num_displays () {
|
||||||
|
|
||||||
|
return alloc_int (System::GetNumDisplays ());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
value lime_system_get_timer () {
|
value lime_system_get_timer () {
|
||||||
|
|
||||||
return alloc_float (System::GetTimer ());
|
return alloc_float (System::GetTimer ());
|
||||||
@@ -1164,7 +1170,6 @@ namespace lime {
|
|||||||
DEFINE_PRIM (lime_bytes_from_data_pointer, 2);
|
DEFINE_PRIM (lime_bytes_from_data_pointer, 2);
|
||||||
DEFINE_PRIM (lime_bytes_get_data_pointer, 1);
|
DEFINE_PRIM (lime_bytes_get_data_pointer, 1);
|
||||||
DEFINE_PRIM (lime_bytes_read_file, 1);
|
DEFINE_PRIM (lime_bytes_read_file, 1);
|
||||||
DEFINE_PRIM (lime_display_get_details, 0);
|
|
||||||
DEFINE_PRIM (lime_font_get_ascender, 1);
|
DEFINE_PRIM (lime_font_get_ascender, 1);
|
||||||
DEFINE_PRIM (lime_font_get_descender, 1);
|
DEFINE_PRIM (lime_font_get_descender, 1);
|
||||||
DEFINE_PRIM (lime_font_get_family_name, 1);
|
DEFINE_PRIM (lime_font_get_family_name, 1);
|
||||||
@@ -1221,6 +1226,8 @@ namespace lime {
|
|||||||
DEFINE_PRIM (lime_renderer_unlock, 1);
|
DEFINE_PRIM (lime_renderer_unlock, 1);
|
||||||
DEFINE_PRIM (lime_render_event_manager_register, 2);
|
DEFINE_PRIM (lime_render_event_manager_register, 2);
|
||||||
DEFINE_PRIM (lime_system_get_directory, 3);
|
DEFINE_PRIM (lime_system_get_directory, 3);
|
||||||
|
DEFINE_PRIM (lime_system_get_display, 1);
|
||||||
|
DEFINE_PRIM (lime_system_get_num_displays, 0);
|
||||||
DEFINE_PRIM (lime_system_get_timer, 0);
|
DEFINE_PRIM (lime_system_get_timer, 0);
|
||||||
DEFINE_PRIM (lime_text_event_manager_register, 2);
|
DEFINE_PRIM (lime_text_event_manager_register, 2);
|
||||||
DEFINE_PRIM (lime_text_layout_create, 3);
|
DEFINE_PRIM (lime_text_layout_create, 3);
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
#include <graphics/PixelFormat.h>
|
|
||||||
#include <math/Rectangle.h>
|
|
||||||
#include <system/Display.h>
|
|
||||||
#include <SDL.h>
|
|
||||||
|
|
||||||
|
|
||||||
namespace lime {
|
|
||||||
|
|
||||||
|
|
||||||
static int id_bounds;
|
|
||||||
static int id_currentMode;
|
|
||||||
static int id_height;
|
|
||||||
static int id_name;
|
|
||||||
static int id_pixelFormat;
|
|
||||||
static int id_refreshRate;
|
|
||||||
static int id_supportedModes;
|
|
||||||
static int id_width;
|
|
||||||
static bool init = false;
|
|
||||||
|
|
||||||
|
|
||||||
value Display::GetDetails () {
|
|
||||||
|
|
||||||
if (!init) {
|
|
||||||
|
|
||||||
id_bounds = val_id ("bounds");
|
|
||||||
id_currentMode = val_id ("currentMode");
|
|
||||||
id_height = val_id ("height");
|
|
||||||
id_name = val_id ("name");
|
|
||||||
id_pixelFormat = val_id ("pixelFormat");
|
|
||||||
id_refreshRate = val_id ("refreshRate");
|
|
||||||
id_supportedModes = val_id ("supportedModes");
|
|
||||||
id_width = val_id ("width");
|
|
||||||
init = true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int numDevices = SDL_GetNumVideoDisplays ();
|
|
||||||
value devices = alloc_array (numDevices);
|
|
||||||
|
|
||||||
value display, supportedModes, mode;
|
|
||||||
int numDisplayModes;
|
|
||||||
SDL_Rect bounds = { 0, 0, 0, 0 };
|
|
||||||
SDL_DisplayMode currentDisplayMode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
|
|
||||||
SDL_DisplayMode displayMode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
|
|
||||||
|
|
||||||
for (int i = 0; i < numDevices; i++) {
|
|
||||||
|
|
||||||
display = alloc_empty_object ();
|
|
||||||
alloc_field (display, id_name, alloc_string (SDL_GetDisplayName (i)));
|
|
||||||
SDL_GetDisplayBounds (i, &bounds);
|
|
||||||
alloc_field (display, id_bounds, Rectangle (bounds.x, bounds.y, bounds.w, bounds.h).Value ());
|
|
||||||
|
|
||||||
SDL_GetCurrentDisplayMode (i, ¤tDisplayMode);
|
|
||||||
numDisplayModes = SDL_GetNumDisplayModes (i);
|
|
||||||
supportedModes = alloc_array (numDisplayModes);
|
|
||||||
|
|
||||||
for (int j = 0; j < numDisplayModes; j++) {
|
|
||||||
|
|
||||||
SDL_GetDisplayMode (i, j, &displayMode);
|
|
||||||
|
|
||||||
if (displayMode.format == currentDisplayMode.format && displayMode.w == currentDisplayMode.w && displayMode.h == currentDisplayMode.h && displayMode.refresh_rate == currentDisplayMode.refresh_rate) {
|
|
||||||
|
|
||||||
alloc_field (display, id_currentMode, alloc_int (j));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
mode = alloc_empty_object ();
|
|
||||||
alloc_field (mode, id_height, alloc_int (displayMode.h));
|
|
||||||
|
|
||||||
switch (displayMode.format) {
|
|
||||||
|
|
||||||
case SDL_PIXELFORMAT_ARGB8888:
|
|
||||||
|
|
||||||
alloc_field (mode, id_pixelFormat, alloc_int (ARGB32));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDL_PIXELFORMAT_BGRA8888:
|
|
||||||
case SDL_PIXELFORMAT_BGRX8888:
|
|
||||||
|
|
||||||
alloc_field (mode, id_pixelFormat, alloc_int (BGRA32));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
|
|
||||||
alloc_field (mode, id_pixelFormat, alloc_int (RGBA32));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
alloc_field (mode, id_refreshRate, alloc_int (displayMode.refresh_rate));
|
|
||||||
alloc_field (mode, id_width, alloc_int (displayMode.w));
|
|
||||||
|
|
||||||
val_array_set_i (supportedModes, j, mode);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
alloc_field (display, id_supportedModes, supportedModes);
|
|
||||||
val_array_set_i (devices, i, display);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return devices;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#include <graphics/PixelFormat.h>
|
||||||
|
#include <math/Rectangle.h>
|
||||||
#include <system/System.h>
|
#include <system/System.h>
|
||||||
|
|
||||||
#ifdef HX_MACOS
|
#ifdef HX_MACOS
|
||||||
@@ -26,15 +28,24 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <SDL_filesystem.h>
|
#include <SDL.h>
|
||||||
#include <SDL_rwops.h>
|
|
||||||
#include <SDL_timer.h>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
namespace lime {
|
namespace lime {
|
||||||
|
|
||||||
|
|
||||||
|
static int id_bounds;
|
||||||
|
static int id_currentMode;
|
||||||
|
static int id_height;
|
||||||
|
static int id_name;
|
||||||
|
static int id_pixelFormat;
|
||||||
|
static int id_refreshRate;
|
||||||
|
static int id_supportedModes;
|
||||||
|
static int id_width;
|
||||||
|
static bool init = false;
|
||||||
|
|
||||||
|
|
||||||
const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) {
|
const char* System::GetDirectory (SystemDirectory type, const char* company, const char* title) {
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@@ -168,6 +179,98 @@ namespace lime {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
value System::GetDisplay (int id) {
|
||||||
|
|
||||||
|
if (!init) {
|
||||||
|
|
||||||
|
id_bounds = val_id ("bounds");
|
||||||
|
id_currentMode = val_id ("currentMode");
|
||||||
|
id_height = val_id ("height");
|
||||||
|
id_name = val_id ("name");
|
||||||
|
id_pixelFormat = val_id ("pixelFormat");
|
||||||
|
id_refreshRate = val_id ("refreshRate");
|
||||||
|
id_supportedModes = val_id ("supportedModes");
|
||||||
|
id_width = val_id ("width");
|
||||||
|
init = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int numDisplays = GetNumDisplays ();
|
||||||
|
|
||||||
|
if (id < 0 || id >= numDisplays) {
|
||||||
|
|
||||||
|
return alloc_null ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
value display = alloc_empty_object ();
|
||||||
|
alloc_field (display, id_name, alloc_string (SDL_GetDisplayName (id)));
|
||||||
|
|
||||||
|
SDL_Rect bounds = { 0, 0, 0, 0 };
|
||||||
|
SDL_GetDisplayBounds (id, &bounds);
|
||||||
|
alloc_field (display, id_bounds, Rectangle (bounds.x, bounds.y, bounds.w, bounds.h).Value ());
|
||||||
|
|
||||||
|
SDL_DisplayMode currentDisplayMode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
|
||||||
|
SDL_DisplayMode displayMode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
SDL_GetCurrentDisplayMode (id, ¤tDisplayMode);
|
||||||
|
|
||||||
|
int numDisplayModes = SDL_GetNumDisplayModes (id);
|
||||||
|
value supportedModes = alloc_array (numDisplayModes);
|
||||||
|
value mode;
|
||||||
|
|
||||||
|
for (int i = 0; i < numDisplayModes; i++) {
|
||||||
|
|
||||||
|
SDL_GetDisplayMode (id, i, &displayMode);
|
||||||
|
|
||||||
|
if (displayMode.format == currentDisplayMode.format && displayMode.w == currentDisplayMode.w && displayMode.h == currentDisplayMode.h && displayMode.refresh_rate == currentDisplayMode.refresh_rate) {
|
||||||
|
|
||||||
|
alloc_field (display, id_currentMode, alloc_int (i));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mode = alloc_empty_object ();
|
||||||
|
alloc_field (mode, id_height, alloc_int (displayMode.h));
|
||||||
|
|
||||||
|
switch (displayMode.format) {
|
||||||
|
|
||||||
|
case SDL_PIXELFORMAT_ARGB8888:
|
||||||
|
|
||||||
|
alloc_field (mode, id_pixelFormat, alloc_int (ARGB32));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SDL_PIXELFORMAT_BGRA8888:
|
||||||
|
case SDL_PIXELFORMAT_BGRX8888:
|
||||||
|
|
||||||
|
alloc_field (mode, id_pixelFormat, alloc_int (BGRA32));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
|
||||||
|
alloc_field (mode, id_pixelFormat, alloc_int (RGBA32));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
alloc_field (mode, id_refreshRate, alloc_int (displayMode.refresh_rate));
|
||||||
|
alloc_field (mode, id_width, alloc_int (displayMode.w));
|
||||||
|
|
||||||
|
val_array_set_i (supportedModes, i, mode);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
alloc_field (display, id_supportedModes, supportedModes);
|
||||||
|
return display;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int System::GetNumDisplays () {
|
||||||
|
|
||||||
|
return SDL_GetNumVideoDisplays ();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double System::GetTimer () {
|
double System::GetTimer () {
|
||||||
|
|
||||||
return SDL_GetTicks ();
|
return SDL_GetTicks ();
|
||||||
|
|||||||
Reference in New Issue
Block a user