@@ -16,26 +16,52 @@ typedef ScreenMode = {
16
16
var framerate : Int ;
17
17
};
18
18
19
+ typedef GLOptions = {
20
+ final major : Int ;
21
+ final minor : Int ;
22
+ final depth : Int ;
23
+ final stencil : Int ;
24
+ final flags : Int ;
25
+ final samples : Int ;
26
+ }
27
+
19
28
@:hlNative (" sdl" )
20
29
class Sdl {
21
30
22
31
static var initDone = false ;
23
32
static var isWin32 = false ;
24
33
25
- public static var requiredGLMajor (default ,null ) = 3 ;
26
- public static var requiredGLMinor (default ,null ) = 2 ;
34
+ public static var glOptions (default ,null ) : GLOptions = {
35
+ major : 3 ,
36
+ minor : 2 ,
37
+ depth : 24 ,
38
+ stencil : 8 ,
39
+ flags : 1 ,
40
+ samples : 1 ,
41
+ };
27
42
28
43
public static function init () {
29
44
if ( initDone ) return ;
30
45
initDone = true ;
31
46
if ( ! initOnce () ) throw " Failed to init SDL" ;
32
47
isWin32 = detectWin32 ();
48
+ var opt = glOptions ;
49
+ gl_options (opt .major , opt .minor , opt .depth , opt .stencil , opt .flags , opt .samples );
50
+ }
51
+
52
+ public static function setGLOptions (options ) {
53
+ glOptions = options ;
33
54
}
34
55
35
- public static function setGLOptions ( major : Int = 3 , minor : Int = 2 , depth : Int = 24 , stencil : Int = 8 , flags : Int = 1 , samples : Int = 1 ) {
36
- requiredGLMajor = major ;
37
- requiredGLMinor = minor ;
38
- glOptions (major , minor , depth , stencil , flags , samples );
56
+ public static function setGLVersion (major , minor ) {
57
+ glOptions = {
58
+ major : major ,
59
+ minor : minor ,
60
+ depth : glOptions .depth ,
61
+ stencil : glOptions .stencil ,
62
+ flags : glOptions .flags ,
63
+ samples : glOptions .samples
64
+ };
39
65
}
40
66
41
67
public static function setHint (name : String , value : String ) {
@@ -52,7 +78,7 @@ class Sdl {
52
78
if ( device == null ) device = " Unknown" ;
53
79
var flags = new haxe. EnumFlags <hl. UI . DialogFlags >();
54
80
flags .set (IsError );
55
- var msg = ' The application was unable to create an OpenGL context\n for your $device video card. \n OpenGL $requiredGLMajor . $ requiredGLMinor + is required, please update your driver.' ;
81
+ var msg = ' The application was unable to create an OpenGL context\n for your $device video card. \n OpenGL ${ glOptions . major } . ${ glOptions . minor } + is required, please update your driver.' ;
56
82
hl. UI .dialog (" OpenGL Error" , msg , flags );
57
83
Sys .exit ( - 1 );
58
84
}
@@ -62,7 +88,7 @@ class Sdl {
62
88
public static inline var GL_COMPATIBILITY_PROFILE = 1 << 2 ;
63
89
public static inline var GL_ES = 1 << 3 ;
64
90
65
- static function glOptions ( major : Int , minor : Int , depth : Int , stencil : Int , flags : Int , samples : Int ) {}
91
+ static function gl_options ( major : Int , minor : Int , depth : Int , stencil : Int , flags : Int , samples : Int ) {}
66
92
67
93
static function initOnce () return false ;
68
94
static function eventLoop ( e : Dynamic ) return false ;
@@ -87,7 +113,7 @@ class Sdl {
87
113
}
88
114
89
115
public static function getScreenWidth (? win : sdl. Window ) : Int {
90
- return
116
+ return
91
117
if (win == null )
92
118
get_screen_width ();
93
119
else
@@ -110,7 +136,7 @@ class Sdl {
110
136
public static function message ( title : String , text : String , error = false ) {
111
137
@:privateAccess messageBox (title .toUtf8 (), text .toUtf8 (), error );
112
138
}
113
-
139
+
114
140
public static function getDisplayModes (display : Window . DisplayHandle ) : Array <ScreenMode > {
115
141
var modes = get_display_modes (display );
116
142
if (modes == null )
@@ -129,7 +155,7 @@ class Sdl {
129
155
var i = 0 ;
130
156
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 } ];
131
157
}
132
-
158
+
133
159
public static function getDevices () {
134
160
var a = [];
135
161
var arr = get_devices ();
@@ -147,7 +173,7 @@ class Sdl {
147
173
public static function setRelativeMouseMode ( enable : Bool ) : Int {
148
174
return 0 ;
149
175
}
150
-
176
+
151
177
public static function setClipboardText ( text : String ) : Bool {
152
178
if ( text == null )
153
179
return false ;
@@ -211,7 +237,7 @@ class Sdl {
211
237
public static function getRelativeMouseMode () : Bool {
212
238
return false ;
213
239
}
214
-
240
+
215
241
public static function warpMouseGlobal ( x : Int , y : Int ) : Int {
216
242
return 0 ;
217
243
}
@@ -233,11 +259,11 @@ class Sdl {
233
259
private static function _getClipboardText () : hl. Bytes {
234
260
return null ;
235
261
}
236
-
262
+
237
263
@:hlNative (" ?sdl" , " set_drag_and_drop_enabled" )
238
264
public static function setDragAndDropEnabled ( v : Bool ): Void {
239
265
}
240
-
266
+
241
267
@:hlNative (" ?sdl" , " get_drag_and_drop_enabled" )
242
268
public static function getDragAndDropEnabled (): Bool {
243
269
return false ;
0 commit comments