display -- adding last implementation bits

This commit is contained in:
Lars A. Doucet
2015-07-30 15:27:28 -05:00
parent 37a16c5971
commit a99ee5af17
4 changed files with 63 additions and 9 deletions

View File

@@ -95,7 +95,8 @@ class Display {
name = lime_display_get_name(id);
mode = lime_display_get_current_display_mode(id);
var obj = lime_display_get_current_display_mode(id);
mode = new DisplayMode(obj.width, obj.height, obj.refreshRate, obj.format);
resolution = new ConstVector2(mode.width, mode.height);
@@ -104,7 +105,8 @@ class Display {
for (i in 0...numModes) {
modes.push(lime_display_get_display_mode(id, i));
obj = lime_display_get_display_mode(id, i);
modes.push(new DisplayMode(obj.width, obj.height, obj.refreshRate, obj.format));
}
}
@@ -133,8 +135,6 @@ class Display {
private static var lime_display_get_name = function(i:Int) {
return "fake";
};
*/
private static var lime_display_get_num_display_modes = function(i:Int) {
return 1;
};
@@ -144,18 +144,16 @@ class Display {
private static var lime_display_get_current_display_mode = function(display:Int):DisplayMode {
return new DisplayMode(1024, 768, 60, 0);
};
*/
#end
#if (cpp || neko || nodejs)
private static var lime_display_get_num_devices = System.load("lime", "lime_display_get_num_devices", 0);
private static var lime_display_get_name = System.load ("lime", "lime_display_get_name", 1);
/*
private static var lime_display_get_num_display_modes = System.load ("lime", "lime_display_get_num_display_modes", 1);
private static var lime_display_get_display_mode = System.load ("lime", "lime_display_get_display_mode", 2);
private static var lime_display_get_current_display_mode = System.load ("lime", "lime_display_get_current_display_mode", 1);
*/
#end
}

View File

@@ -2,6 +2,7 @@
#define LIME_SYSTEM_DISPLAY_H
#include <SDL.h>
#include <hx/CFFI.h>
namespace lime {
@@ -10,10 +11,11 @@ namespace lime {
public:
value Display::GetCurrentDisplayMode (int displayIndex);
value Display::GetDisplayMode (int displayIndex, int modeIndex);
static int GetNumDevices ();
static const char* GetDisplayName (int displayIndex);
};
static int GetNumDisplayModes (int displayIndex);
}

View File

@@ -391,6 +391,18 @@ namespace lime {
}
value lime_display_get_current_display_mode (value displayIndex) {
return Display::GetCurrentDisplayMode(displayIndex);
}
value lime_display_get_display_mode (value displayIndex, value modeIndex) {
return Display::GetCurrentDisplayMode(displayIndex, modeIndex);
}
value lime_display_get_name (value displayIndex) {
return alloc_string (Display::GetDisplayName (val_int (displayIndex)));
@@ -403,6 +415,12 @@ namespace lime {
}
value lime_display_get_num_display_modes (value displayIndex) {
return alloc_int (Display::GetNumDisplayModes(val_int (displayIndex));
}
value lime_gamepad_add_mappings (value mappings) {
int length = val_array_size (mappings);
@@ -1184,8 +1202,11 @@ namespace lime {
DEFINE_PRIM (lime_font_render_glyph, 3);
DEFINE_PRIM (lime_font_render_glyphs, 3);
DEFINE_PRIM (lime_font_set_size, 2);
DEFINE_PRIM (lime_display_get_current_display_mode, 1);
DEFINE_PRIM (lime_display_get_display_mode, 2);
DEFINE_PRIM (lime_display_get_name, 1);
DEFINE_PRIM (lime_display_get_num_devices, 0);
DEFINE_PRIM (lime_display_get_num_display_modes, 1);
DEFINE_PRIM (lime_gamepad_add_mappings, 1);
DEFINE_PRIM (lime_gamepad_event_manager_register, 2);
DEFINE_PRIM (lime_gamepad_get_device_guid, 1);

View File

@@ -4,6 +4,33 @@
namespace lime {
value Display::GetCurrentDisplayMode (int displayIndex) {
SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
SDL_GetCurrentDisplayMode(displayIndex, mode);
value mValue = alloc_empty_object ();
alloc_field (mValue, val_id("w"), alloc_int(mode.w));
alloc_field (mValue, val_id("h"), alloc_int(mode.h));
alloc_field (mValue, val_id("refresh_rate"), alloc_int(mode.refresh_rate));
alloc_field (mValue, val_id("format"), alloc_int(mode.format));
return mValue;
}
value Display::GetDisplayMode (int displayIndex, int modeIndex) {
SDL_DisplayMode mode = { SDL_PIXELFORMAT_UNKNOWN, 0, 0, 0, 0 };
SDL_GetDisplayMode(displayIndex, modeIndex, mode);
value mValue = alloc_empty_object ();
alloc_field (mValue, val_id("w"), alloc_int(mode.w));
alloc_field (mValue, val_id("h"), alloc_int(mode.h));
alloc_field (mValue, val_id("refresh_rate"), alloc_int(mode.refresh_rate));
alloc_field (mValue, val_id("format"), alloc_int(mode.format));
return mValue;
}
int Display::GetNumDevices() {
return SDL_GetNumVideoDisplays();
@@ -16,4 +43,10 @@ namespace lime {
}
int Display::GetNumDisplayModes (int displayIndex) {
return SDL_GetNumDisplayModes(displayIndex);
}
}