|
@@ -16,26 +16,52 @@ typedef ScreenMode = {
|
|
var framerate : Int;
|
|
var framerate : Int;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+typedef GLOptions = {
|
|
|
|
+ final major : Int;
|
|
|
|
+ final minor : Int;
|
|
|
|
+ final depth : Int;
|
|
|
|
+ final stencil : Int;
|
|
|
|
+ final flags : Int;
|
|
|
|
+ final samples : Int;
|
|
|
|
+}
|
|
|
|
+
|
|
@:hlNative("sdl")
|
|
@:hlNative("sdl")
|
|
class Sdl {
|
|
class Sdl {
|
|
|
|
|
|
static var initDone = false;
|
|
static var initDone = false;
|
|
static var isWin32 = false;
|
|
static var isWin32 = false;
|
|
|
|
|
|
- public static var requiredGLMajor(default,null) = 3;
|
|
|
|
- public static var requiredGLMinor(default,null) = 2;
|
|
|
|
|
|
+ public static var glOptions(default,null) : GLOptions = {
|
|
|
|
+ major : 3,
|
|
|
|
+ minor : 2,
|
|
|
|
+ depth : 24,
|
|
|
|
+ stencil : 8,
|
|
|
|
+ flags : 1,
|
|
|
|
+ samples : 1,
|
|
|
|
+ };
|
|
|
|
|
|
public static function init() {
|
|
public static function init() {
|
|
if( initDone ) return;
|
|
if( initDone ) return;
|
|
initDone = true;
|
|
initDone = true;
|
|
if( !initOnce() ) throw "Failed to init SDL";
|
|
if( !initOnce() ) throw "Failed to init SDL";
|
|
isWin32 = detectWin32();
|
|
isWin32 = detectWin32();
|
|
|
|
+ var opt = glOptions;
|
|
|
|
+ gl_options(opt.major, opt.minor, opt.depth, opt.stencil, opt.flags, opt.samples);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static function setGLOptions(options) {
|
|
|
|
+ glOptions = options;
|
|
}
|
|
}
|
|
|
|
|
|
- public static function setGLOptions( major : Int = 3, minor : Int = 2, depth : Int = 24, stencil : Int = 8, flags : Int = 1, samples : Int = 1 ) {
|
|
|
|
- requiredGLMajor = major;
|
|
|
|
- requiredGLMinor = minor;
|
|
|
|
- glOptions(major, minor, depth, stencil, flags, samples);
|
|
|
|
|
|
+ public static function setGLVersion(major, minor) {
|
|
|
|
+ glOptions = {
|
|
|
|
+ major : major,
|
|
|
|
+ minor : minor,
|
|
|
|
+ depth : glOptions.depth,
|
|
|
|
+ stencil : glOptions.stencil,
|
|
|
|
+ flags : glOptions.flags,
|
|
|
|
+ samples : glOptions.samples
|
|
|
|
+ };
|
|
}
|
|
}
|
|
|
|
|
|
public static function setHint(name:String, value:String) {
|
|
public static function setHint(name:String, value:String) {
|
|
@@ -52,7 +78,7 @@ class Sdl {
|
|
if( device == null ) device = "Unknown";
|
|
if( device == null ) device = "Unknown";
|
|
var flags = new haxe.EnumFlags<hl.UI.DialogFlags>();
|
|
var flags = new haxe.EnumFlags<hl.UI.DialogFlags>();
|
|
flags.set(IsError);
|
|
flags.set(IsError);
|
|
- var msg = 'The application was unable to create an OpenGL context\nfor your $device video card.\nOpenGL $requiredGLMajor.$requiredGLMinor+ is required, please update your driver.';
|
|
|
|
|
|
+ var msg = 'The application was unable to create an OpenGL context\nfor your $device video card.\nOpenGL ${glOptions.major}.${glOptions.minor}+ is required, please update your driver.';
|
|
hl.UI.dialog("OpenGL Error", msg, flags);
|
|
hl.UI.dialog("OpenGL Error", msg, flags);
|
|
Sys.exit( -1);
|
|
Sys.exit( -1);
|
|
}
|
|
}
|
|
@@ -62,7 +88,7 @@ class Sdl {
|
|
public static inline var GL_COMPATIBILITY_PROFILE = 1 << 2;
|
|
public static inline var GL_COMPATIBILITY_PROFILE = 1 << 2;
|
|
public static inline var GL_ES = 1 << 3;
|
|
public static inline var GL_ES = 1 << 3;
|
|
|
|
|
|
- static function glOptions( major : Int, minor : Int, depth : Int, stencil : Int, flags : Int, samples : Int ) {}
|
|
|
|
|
|
+ static function gl_options( major : Int, minor : Int, depth : Int, stencil : Int, flags : Int, samples : Int ) {}
|
|
|
|
|
|
static function initOnce() return false;
|
|
static function initOnce() return false;
|
|
static function eventLoop( e : Dynamic ) return false;
|
|
static function eventLoop( e : Dynamic ) return false;
|
|
@@ -87,7 +113,7 @@ class Sdl {
|
|
}
|
|
}
|
|
|
|
|
|
public static function getScreenWidth(?win : sdl.Window) : Int {
|
|
public static function getScreenWidth(?win : sdl.Window) : Int {
|
|
- return
|
|
|
|
|
|
+ return
|
|
if(win == null)
|
|
if(win == null)
|
|
get_screen_width();
|
|
get_screen_width();
|
|
else
|
|
else
|
|
@@ -110,7 +136,7 @@ class Sdl {
|
|
public static function message( title : String, text : String, error = false ) {
|
|
public static function message( title : String, text : String, error = false ) {
|
|
@:privateAccess messageBox(title.toUtf8(), text.toUtf8(), error);
|
|
@:privateAccess messageBox(title.toUtf8(), text.toUtf8(), error);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static function getDisplayModes(display : Window.DisplayHandle) : Array<ScreenMode> {
|
|
public static function getDisplayModes(display : Window.DisplayHandle) : Array<ScreenMode> {
|
|
var modes = get_display_modes(display);
|
|
var modes = get_display_modes(display);
|
|
if(modes == null)
|
|
if(modes == null)
|
|
@@ -129,7 +155,7 @@ class Sdl {
|
|
var i = 0;
|
|
var i = 0;
|
|
return [ for(d in get_displays() ) @:privateAccess { handle: d.handle, name: '${String.fromUTF8(d.name)} (${++i})', left: d.left, top: d.top, right: d.right, bottom: d.bottom } ];
|
|
return [ for(d in get_displays() ) @:privateAccess { handle: d.handle, name: '${String.fromUTF8(d.name)} (${++i})', left: d.left, top: d.top, right: d.right, bottom: d.bottom } ];
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static function getDevices() {
|
|
public static function getDevices() {
|
|
var a = [];
|
|
var a = [];
|
|
var arr = get_devices();
|
|
var arr = get_devices();
|
|
@@ -147,7 +173,7 @@ class Sdl {
|
|
public static function setRelativeMouseMode( enable : Bool ) : Int {
|
|
public static function setRelativeMouseMode( enable : Bool ) : Int {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static function setClipboardText( text : String ) : Bool {
|
|
public static function setClipboardText( text : String ) : Bool {
|
|
if( text == null )
|
|
if( text == null )
|
|
return false;
|
|
return false;
|
|
@@ -211,7 +237,7 @@ class Sdl {
|
|
public static function getRelativeMouseMode() : Bool {
|
|
public static function getRelativeMouseMode() : Bool {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
public static function warpMouseGlobal( x : Int, y : Int ) : Int {
|
|
public static function warpMouseGlobal( x : Int, y : Int ) : Int {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@@ -233,11 +259,11 @@ class Sdl {
|
|
private static function _getClipboardText() : hl.Bytes {
|
|
private static function _getClipboardText() : hl.Bytes {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@:hlNative("?sdl", "set_drag_and_drop_enabled")
|
|
@:hlNative("?sdl", "set_drag_and_drop_enabled")
|
|
public static function setDragAndDropEnabled( v : Bool ): Void {
|
|
public static function setDragAndDropEnabled( v : Bool ): Void {
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
@:hlNative("?sdl", "get_drag_and_drop_enabled")
|
|
@:hlNative("?sdl", "get_drag_and_drop_enabled")
|
|
public static function getDragAndDropEnabled(): Bool {
|
|
public static function getDragAndDropEnabled(): Bool {
|
|
return false;
|
|
return false;
|