@kmamal/sdl 0.4.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -46,18 +46,24 @@ const handleEvents = () => {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
case 'minimize': {
|
|
49
|
+
window._visible = false
|
|
49
50
|
window._minimized = true
|
|
50
51
|
window._maximized = false
|
|
52
|
+
window._fullscreen = false
|
|
51
53
|
break
|
|
52
54
|
}
|
|
53
55
|
case 'maximize': {
|
|
56
|
+
window._visible = true
|
|
54
57
|
window._minimized = false
|
|
55
58
|
window._maximized = true
|
|
59
|
+
window._fullscreen = false
|
|
56
60
|
break
|
|
57
61
|
}
|
|
58
62
|
case 'restore': {
|
|
63
|
+
window._visible = true
|
|
59
64
|
window._minimized = false
|
|
60
65
|
window._maximized = false
|
|
66
|
+
window._fullscreen = false
|
|
61
67
|
break
|
|
62
68
|
}
|
|
63
69
|
|
|
@@ -101,15 +101,15 @@ class Window extends EventsViaPoll {
|
|
|
101
101
|
this._y = result.y
|
|
102
102
|
this._width = result.width
|
|
103
103
|
this._height = result.height
|
|
104
|
+
this._fullscreen = result.fullscreen
|
|
105
|
+
this._resizable = result.resizable
|
|
106
|
+
this._borderless = result.borderless
|
|
107
|
+
this._accelerated = result.accelerated
|
|
108
|
+
this._vsync = result.vsync
|
|
104
109
|
this._native = result.native
|
|
105
110
|
|
|
106
111
|
this._title = title
|
|
107
112
|
this._visible = visible
|
|
108
|
-
this._fullscreen = fullscreen
|
|
109
|
-
this._resizable = resizable
|
|
110
|
-
this._borderless = borderless
|
|
111
|
-
this._accelerated = accelerated
|
|
112
|
-
this._vsync = vsync
|
|
113
113
|
this._opengl = opengl
|
|
114
114
|
|
|
115
115
|
this._focused = false
|
|
@@ -139,8 +139,9 @@ class Window extends EventsViaPoll {
|
|
|
139
139
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
140
140
|
|
|
141
141
|
if (typeof title !== 'string') { throw Object.assign(new Error("title must be a string"), { title }) }
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
Bindings.window_setTitle(this._id, title)
|
|
144
|
+
this._title = title
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
get x () { return this._x }
|
|
@@ -150,9 +151,10 @@ class Window extends EventsViaPoll {
|
|
|
150
151
|
|
|
151
152
|
if (!Number.isFinite(x)) { throw Object.assign(new Error("x must be a number"), { x }) }
|
|
152
153
|
if (!Number.isFinite(y)) { throw Object.assign(new Error("y must be a number"), { y }) }
|
|
154
|
+
|
|
155
|
+
Bindings.window_setPosition(this._id, x, y)
|
|
153
156
|
this._x = x
|
|
154
157
|
this._y = y
|
|
155
|
-
Bindings.window_setPosition(this._id, x, y)
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
get width () { return this._width }
|
|
@@ -164,17 +166,20 @@ class Window extends EventsViaPoll {
|
|
|
164
166
|
if (width <= 0) { throw Object.assign(new Error("invalid width"), { width }) }
|
|
165
167
|
if (!Number.isFinite(height)) { throw Object.assign(new Error("height must be a number"), { height }) }
|
|
166
168
|
if (height <= 0) { throw Object.assign(new Error("invalid height"), { height }) }
|
|
169
|
+
|
|
167
170
|
Bindings.window_setSize(this._id, width, height)
|
|
171
|
+
this._width = width
|
|
172
|
+
this._height = height
|
|
168
173
|
}
|
|
169
174
|
|
|
170
175
|
get visible () { return this._visible }
|
|
171
176
|
show (show = true) {
|
|
172
177
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
173
178
|
|
|
179
|
+
if (typeof show !== 'boolean') { throw Object.assign(new Error("show must be a boolean"), { show }) }
|
|
180
|
+
|
|
181
|
+
show ? Bindings.window_show(this._id) : Bindings.window_hide(this._id)
|
|
174
182
|
this._visible = show
|
|
175
|
-
show
|
|
176
|
-
? Bindings.window_show(this._id)
|
|
177
|
-
: Bindings.window_hide(this._id)
|
|
178
183
|
}
|
|
179
184
|
|
|
180
185
|
hide () { this.show(false) }
|
|
@@ -184,8 +189,8 @@ class Window extends EventsViaPoll {
|
|
|
184
189
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
185
190
|
|
|
186
191
|
if (typeof fullscreen !== 'boolean') { throw Object.assign(new Error("fullscreen must be a boolean"), { fullscreen }) }
|
|
187
|
-
|
|
188
|
-
Bindings.window_setFullscreen(this._id, fullscreen)
|
|
192
|
+
|
|
193
|
+
this._fullscreen = Bindings.window_setFullscreen(this._id, fullscreen)
|
|
189
194
|
}
|
|
190
195
|
|
|
191
196
|
get resizable () { return this._resizable }
|
|
@@ -193,8 +198,8 @@ class Window extends EventsViaPoll {
|
|
|
193
198
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
194
199
|
|
|
195
200
|
if (typeof resizable !== 'boolean') { throw Object.assign(new Error("resizable must be a boolean"), { resizable }) }
|
|
196
|
-
|
|
197
|
-
Bindings.window_setResizable(this._id, resizable)
|
|
201
|
+
|
|
202
|
+
this._resizable = Bindings.window_setResizable(this._id, resizable)
|
|
198
203
|
}
|
|
199
204
|
|
|
200
205
|
get borderless () { return this._borderless }
|
|
@@ -202,8 +207,8 @@ class Window extends EventsViaPoll {
|
|
|
202
207
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
203
208
|
|
|
204
209
|
if (typeof borderless !== 'boolean') { throw Object.assign(new Error("borderless must be a boolean"), { borderless }) }
|
|
205
|
-
|
|
206
|
-
Bindings.window_setBorderless(this._id, borderless)
|
|
210
|
+
|
|
211
|
+
this._borderless = Bindings.window_setBorderless(this._id, borderless)
|
|
207
212
|
}
|
|
208
213
|
|
|
209
214
|
get accelerated () { return this._accelerated }
|
|
@@ -211,8 +216,8 @@ class Window extends EventsViaPoll {
|
|
|
211
216
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
212
217
|
|
|
213
218
|
if (typeof accelerated !== 'boolean') { throw Object.assign(new Error("accelerated must be a boolean"), { accelerated }) }
|
|
214
|
-
|
|
215
|
-
Bindings.window_setAcceleratedAndVsync(this._id, accelerated, this._vsync)
|
|
219
|
+
|
|
220
|
+
[ this._accelerated, this._vsync ] = Bindings.window_setAcceleratedAndVsync(this._id, accelerated, this._vsync)
|
|
216
221
|
}
|
|
217
222
|
|
|
218
223
|
get vsync () { return this._vsync }
|
|
@@ -220,8 +225,8 @@ class Window extends EventsViaPoll {
|
|
|
220
225
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
221
226
|
|
|
222
227
|
if (typeof vsync !== 'boolean') { throw Object.assign(new Error("vsync must be a boolean"), { vsync }) }
|
|
223
|
-
|
|
224
|
-
Bindings.window_setAcceleratedAndVsync(this._id, this._accelerated, vsync)
|
|
228
|
+
|
|
229
|
+
[ this._accelerated, this._vsync ] = Bindings.window_setAcceleratedAndVsync(this._id, this._accelerated, vsync)
|
|
225
230
|
}
|
|
226
231
|
|
|
227
232
|
get opengl () { return this._opengl }
|
|
@@ -231,25 +236,32 @@ class Window extends EventsViaPoll {
|
|
|
231
236
|
minimize () {
|
|
232
237
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
233
238
|
|
|
234
|
-
this._minimized = true
|
|
235
239
|
Bindings.window_minimize(this._id)
|
|
240
|
+
this._visible = false
|
|
241
|
+
this._minimized = true
|
|
242
|
+
this._maximized = false
|
|
243
|
+
this._fullscreen = false
|
|
236
244
|
}
|
|
237
245
|
|
|
238
246
|
get maximized () { return this._maximized }
|
|
239
247
|
maximize () {
|
|
240
248
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
241
249
|
|
|
242
|
-
this._maximized = true
|
|
243
|
-
this._visible = true
|
|
244
250
|
Bindings.window_maximize(this._id)
|
|
251
|
+
this._visible = true
|
|
252
|
+
this._minimized = false
|
|
253
|
+
this._maximized = true
|
|
254
|
+
this._fullscreen = false
|
|
245
255
|
}
|
|
246
256
|
|
|
247
257
|
restore () {
|
|
248
258
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
249
259
|
|
|
250
|
-
this._maximized = false
|
|
251
|
-
this._minimized = false
|
|
252
260
|
Bindings.window_restore(this._id)
|
|
261
|
+
this._visible = true
|
|
262
|
+
this._minimized = false
|
|
263
|
+
this._maximized = false
|
|
264
|
+
this._fullscreen = false
|
|
253
265
|
}
|
|
254
266
|
|
|
255
267
|
get focused () { return this._focused }
|
|
@@ -257,6 +269,8 @@ class Window extends EventsViaPoll {
|
|
|
257
269
|
if (this._destroyed) { throw Object.assign(new Error("window is destroyed"), { id: this._id }) }
|
|
258
270
|
|
|
259
271
|
Bindings.window_focus(this._id)
|
|
272
|
+
this._focused = true
|
|
273
|
+
Globals.windows.focused = this
|
|
260
274
|
}
|
|
261
275
|
|
|
262
276
|
get hovered () { return this._hovered }
|
|
@@ -307,8 +321,10 @@ class Window extends EventsViaPoll {
|
|
|
307
321
|
|
|
308
322
|
if (Globals.windows.hovered === this) { Globals.windows.hovered = null }
|
|
309
323
|
if (Globals.windows.focused === this) { Globals.windows.focused = null }
|
|
310
|
-
|
|
324
|
+
|
|
311
325
|
Bindings.window_destroy(this._id)
|
|
326
|
+
this._destroyed = true
|
|
327
|
+
|
|
312
328
|
Globals.windows.all.delete(this._id)
|
|
313
329
|
|
|
314
330
|
maybeTriggerQuit()
|
package/src/native/binding.cpp
CHANGED
|
@@ -283,7 +283,7 @@ window_create(napi_env env, napi_callback_info info)
|
|
|
283
283
|
CALL_SDL_HELPER(window_create,
|
|
284
284
|
title, display,
|
|
285
285
|
&x, &y, &width, &height,
|
|
286
|
-
visible, fullscreen, resizable, borderless, accelerated, vsync, opengl,
|
|
286
|
+
visible, &fullscreen, &resizable, &borderless, &accelerated, &vsync, opengl,
|
|
287
287
|
&window_id, &native_pointer, &native_pointer_size
|
|
288
288
|
);
|
|
289
289
|
|
|
@@ -310,6 +310,31 @@ window_create(napi_env env, napi_callback_info info)
|
|
|
310
310
|
CALL_NAPI(napi_create_string_latin1, "height", 6, &key);
|
|
311
311
|
CALL_NAPI(napi_set_property, result, key, value);
|
|
312
312
|
|
|
313
|
+
CALL_NAPI(napi_create_int32, fullscreen, &value);
|
|
314
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
315
|
+
CALL_NAPI(napi_create_string_latin1, "fullscreen", 10, &key);
|
|
316
|
+
CALL_NAPI(napi_set_property, result, key, value);
|
|
317
|
+
|
|
318
|
+
CALL_NAPI(napi_create_int32, resizable, &value);
|
|
319
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
320
|
+
CALL_NAPI(napi_create_string_latin1, "resizable", 9, &key);
|
|
321
|
+
CALL_NAPI(napi_set_property, result, key, value);
|
|
322
|
+
|
|
323
|
+
CALL_NAPI(napi_create_int32, borderless, &value);
|
|
324
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
325
|
+
CALL_NAPI(napi_create_string_latin1, "borderless", 10, &key);
|
|
326
|
+
CALL_NAPI(napi_set_property, result, key, value);
|
|
327
|
+
|
|
328
|
+
CALL_NAPI(napi_create_int32, accelerated, &value);
|
|
329
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
330
|
+
CALL_NAPI(napi_create_string_latin1, "accelerated", 11, &key);
|
|
331
|
+
CALL_NAPI(napi_set_property, result, key, value);
|
|
332
|
+
|
|
333
|
+
CALL_NAPI(napi_create_int32, vsync, &value);
|
|
334
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
335
|
+
CALL_NAPI(napi_create_string_latin1, "vsync", 5, &key);
|
|
336
|
+
CALL_NAPI(napi_set_property, result, key, value);
|
|
337
|
+
|
|
313
338
|
if (native_pointer) {
|
|
314
339
|
CALL_NAPI(napi_create_external_buffer,
|
|
315
340
|
native_pointer_size, native_pointer, freePointer, native_pointer,
|
|
@@ -394,6 +419,8 @@ window_setSize(napi_env env, napi_callback_info info)
|
|
|
394
419
|
napi_value
|
|
395
420
|
window_setFullscreen(napi_env env, napi_callback_info info)
|
|
396
421
|
{
|
|
422
|
+
napi_value result = nullptr;
|
|
423
|
+
|
|
397
424
|
napi_value argv[2];
|
|
398
425
|
size_t argc = sizeof(argv) / sizeof(napi_value);
|
|
399
426
|
CALL_NAPI(napi_get_cb_info, info, &argc, argv, nullptr, nullptr);
|
|
@@ -404,15 +431,20 @@ window_setFullscreen(napi_env env, napi_callback_info info)
|
|
|
404
431
|
bool fullscreen;
|
|
405
432
|
CALL_NAPI(napi_get_value_bool, argv[1], &fullscreen);
|
|
406
433
|
|
|
407
|
-
CALL_SDL_HELPER(window_setFullscreen, window_id, fullscreen);
|
|
434
|
+
CALL_SDL_HELPER(window_setFullscreen, window_id, &fullscreen);
|
|
435
|
+
|
|
436
|
+
CALL_NAPI(napi_create_int32, fullscreen, &result);
|
|
437
|
+
CALL_NAPI(napi_coerce_to_bool, result, &result);
|
|
408
438
|
|
|
409
439
|
cleanup:
|
|
410
|
-
return
|
|
440
|
+
return result;
|
|
411
441
|
}
|
|
412
442
|
|
|
413
443
|
napi_value
|
|
414
444
|
window_setResizable(napi_env env, napi_callback_info info)
|
|
415
445
|
{
|
|
446
|
+
napi_value result = nullptr;
|
|
447
|
+
|
|
416
448
|
napi_value argv[2];
|
|
417
449
|
size_t argc = sizeof(argv) / sizeof(napi_value);
|
|
418
450
|
CALL_NAPI(napi_get_cb_info, info, &argc, argv, nullptr, nullptr);
|
|
@@ -423,15 +455,20 @@ window_setResizable(napi_env env, napi_callback_info info)
|
|
|
423
455
|
bool resizable;
|
|
424
456
|
CALL_NAPI(napi_get_value_bool, argv[1], &resizable);
|
|
425
457
|
|
|
426
|
-
CALL_SDL_HELPER(window_setResizable, window_id, resizable);
|
|
458
|
+
CALL_SDL_HELPER(window_setResizable, window_id, &resizable);
|
|
459
|
+
|
|
460
|
+
CALL_NAPI(napi_create_int32, resizable, &result);
|
|
461
|
+
CALL_NAPI(napi_coerce_to_bool, result, &result);
|
|
427
462
|
|
|
428
463
|
cleanup:
|
|
429
|
-
return
|
|
464
|
+
return result;
|
|
430
465
|
}
|
|
431
466
|
|
|
432
467
|
napi_value
|
|
433
468
|
window_setBorderless(napi_env env, napi_callback_info info)
|
|
434
469
|
{
|
|
470
|
+
napi_value result = nullptr;
|
|
471
|
+
|
|
435
472
|
napi_value argv[2];
|
|
436
473
|
size_t argc = sizeof(argv) / sizeof(napi_value);
|
|
437
474
|
CALL_NAPI(napi_get_cb_info, info, &argc, argv, nullptr, nullptr);
|
|
@@ -442,15 +479,20 @@ window_setBorderless(napi_env env, napi_callback_info info)
|
|
|
442
479
|
bool borderless;
|
|
443
480
|
CALL_NAPI(napi_get_value_bool, argv[1], &borderless);
|
|
444
481
|
|
|
445
|
-
CALL_SDL_HELPER(window_setBorderless, window_id, borderless);
|
|
482
|
+
CALL_SDL_HELPER(window_setBorderless, window_id, &borderless);
|
|
483
|
+
|
|
484
|
+
CALL_NAPI(napi_create_int32, borderless, &result);
|
|
485
|
+
CALL_NAPI(napi_coerce_to_bool, result, &result);
|
|
446
486
|
|
|
447
487
|
cleanup:
|
|
448
|
-
return
|
|
488
|
+
return result;
|
|
449
489
|
}
|
|
450
490
|
|
|
451
491
|
napi_value
|
|
452
492
|
window_setAcceleratedAndVsync(napi_env env, napi_callback_info info)
|
|
453
493
|
{
|
|
494
|
+
napi_value result = nullptr;
|
|
495
|
+
|
|
454
496
|
napi_value argv[3];
|
|
455
497
|
size_t argc = sizeof(argv) / sizeof(napi_value);
|
|
456
498
|
CALL_NAPI(napi_get_cb_info, info, &argc, argv, nullptr, nullptr);
|
|
@@ -462,10 +504,21 @@ window_setAcceleratedAndVsync(napi_env env, napi_callback_info info)
|
|
|
462
504
|
CALL_NAPI(napi_get_value_bool, argv[1], &accelerated);
|
|
463
505
|
CALL_NAPI(napi_get_value_bool, argv[2], &vsync);
|
|
464
506
|
|
|
465
|
-
CALL_SDL_HELPER(window_setAcceleratedAndVsync, window_id, accelerated, vsync);
|
|
507
|
+
CALL_SDL_HELPER(window_setAcceleratedAndVsync, window_id, &accelerated, &vsync);
|
|
508
|
+
|
|
509
|
+
CALL_NAPI(napi_create_array, &result);
|
|
510
|
+
napi_value value;
|
|
511
|
+
|
|
512
|
+
CALL_NAPI(napi_create_int32, accelerated, &value);
|
|
513
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
514
|
+
CALL_NAPI(napi_set_element, result, 0, value);
|
|
515
|
+
|
|
516
|
+
CALL_NAPI(napi_create_int32, vsync, &value);
|
|
517
|
+
CALL_NAPI(napi_coerce_to_bool, value, &value);
|
|
518
|
+
CALL_NAPI(napi_set_element, result, 1, value);
|
|
466
519
|
|
|
467
520
|
cleanup:
|
|
468
|
-
return
|
|
521
|
+
return result;
|
|
469
522
|
}
|
|
470
523
|
|
|
471
524
|
napi_value
|
|
@@ -744,8 +744,8 @@ _updateTexture(
|
|
|
744
744
|
ErrorMessage *
|
|
745
745
|
_updateRenderer(
|
|
746
746
|
SDL_Window * window,
|
|
747
|
-
bool accelerated,
|
|
748
|
-
bool vsync
|
|
747
|
+
bool * accelerated,
|
|
748
|
+
bool * vsync
|
|
749
749
|
) {
|
|
750
750
|
int window_id = SDL_GetWindowID(window);
|
|
751
751
|
|
|
@@ -753,8 +753,8 @@ _updateRenderer(
|
|
|
753
753
|
if (old_renderer != nullptr) { SDL_DestroyRenderer(old_renderer); }
|
|
754
754
|
|
|
755
755
|
int renderer_flags = 0
|
|
756
|
-
| (accelerated ? SDL_RENDERER_ACCELERATED : SDL_RENDERER_SOFTWARE)
|
|
757
|
-
| (accelerated && vsync ? SDL_RENDERER_PRESENTVSYNC : 0);
|
|
756
|
+
| (*accelerated ? SDL_RENDERER_ACCELERATED : SDL_RENDERER_SOFTWARE)
|
|
757
|
+
| (*accelerated && *vsync ? SDL_RENDERER_PRESENTVSYNC : 0);
|
|
758
758
|
|
|
759
759
|
SDL_Renderer * renderer = SDL_CreateRenderer(window, -1, renderer_flags);
|
|
760
760
|
if (renderer == nullptr) {
|
|
@@ -764,6 +764,9 @@ _updateRenderer(
|
|
|
764
764
|
SDL_RendererInfo info;
|
|
765
765
|
SDL_GetRendererInfo(renderer, &info);
|
|
766
766
|
|
|
767
|
+
*accelerated = info.flags & SDL_RENDERER_ACCELERATED;
|
|
768
|
+
*vsync = info.flags & SDL_RENDERER_PRESENTVSYNC;
|
|
769
|
+
|
|
767
770
|
int width, height;
|
|
768
771
|
SDL_GetWindowSize(window, &width, &height);
|
|
769
772
|
int format = SDL_GetWindowPixelFormat(window);
|
|
@@ -778,11 +781,11 @@ window_create (
|
|
|
778
781
|
const char * title, int display,
|
|
779
782
|
int ** x, int ** y, int ** width, int ** height,
|
|
780
783
|
bool visible,
|
|
781
|
-
bool fullscreen,
|
|
782
|
-
bool resizable,
|
|
783
|
-
bool borderless,
|
|
784
|
-
bool accelerated,
|
|
785
|
-
bool vsync,
|
|
784
|
+
bool * fullscreen,
|
|
785
|
+
bool * resizable,
|
|
786
|
+
bool * borderless,
|
|
787
|
+
bool * accelerated,
|
|
788
|
+
bool * vsync,
|
|
786
789
|
bool opengl,
|
|
787
790
|
int * window_id, void ** native_pointer, int * native_pointer_size
|
|
788
791
|
) {
|
|
@@ -804,20 +807,25 @@ window_create (
|
|
|
804
807
|
*height = (int *) malloc(sizeof(int));
|
|
805
808
|
**height = 480;
|
|
806
809
|
}
|
|
807
|
-
int
|
|
810
|
+
int desired_flags = 0
|
|
808
811
|
| (visible ? 0 : SDL_WINDOW_HIDDEN)
|
|
809
|
-
| (fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)
|
|
810
|
-
| (resizable ? SDL_WINDOW_RESIZABLE : 0)
|
|
811
|
-
| (borderless ? SDL_WINDOW_BORDERLESS : 0)
|
|
812
|
+
| (*fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0)
|
|
813
|
+
| (*resizable ? SDL_WINDOW_RESIZABLE : 0)
|
|
814
|
+
| (*borderless ? SDL_WINDOW_BORDERLESS : 0)
|
|
812
815
|
| (opengl ? SDL_WINDOW_OPENGL : 0);
|
|
813
816
|
|
|
814
|
-
window = SDL_CreateWindow(title, **x, **y, **width, **height,
|
|
817
|
+
window = SDL_CreateWindow(title, **x, **y, **width, **height, desired_flags);
|
|
815
818
|
if (window == nullptr) {
|
|
816
819
|
RETURN_ERROR("SDL_CreateWindow() error: %s\n", SDL_GetError());
|
|
817
820
|
}
|
|
818
821
|
|
|
819
822
|
SDL_GetWindowPosition(window, *x, *y);
|
|
820
823
|
|
|
824
|
+
int actual_flags = SDL_GetWindowFlags(window);
|
|
825
|
+
*fullscreen = actual_flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
826
|
+
*resizable = actual_flags & SDL_WINDOW_RESIZABLE;
|
|
827
|
+
*borderless = actual_flags & SDL_WINDOW_BORDERLESS;
|
|
828
|
+
|
|
821
829
|
*window_id = SDL_GetWindowID(window);
|
|
822
830
|
if (*window_id == 0) {
|
|
823
831
|
RETURN_ERROR("SDL_GetWindowID() error: %s\n", SDL_GetError());
|
|
@@ -882,48 +890,57 @@ window_setSize (int window_id, int width, int height)
|
|
|
882
890
|
}
|
|
883
891
|
|
|
884
892
|
ErrorMessage *
|
|
885
|
-
window_setFullscreen (int window_id, bool fullscreen)
|
|
893
|
+
window_setFullscreen (int window_id, bool * fullscreen)
|
|
886
894
|
{
|
|
887
895
|
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
888
896
|
if (window == nullptr) {
|
|
889
897
|
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
890
898
|
}
|
|
891
899
|
|
|
892
|
-
if (SDL_SetWindowFullscreen(window, fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) != 0) {
|
|
893
|
-
RETURN_ERROR("SDL_SetWindowFullscreen(%d, %d) error: %s\n", window_id, fullscreen, SDL_GetError());
|
|
900
|
+
if (SDL_SetWindowFullscreen(window, *fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0) != 0) {
|
|
901
|
+
RETURN_ERROR("SDL_SetWindowFullscreen(%d, %d) error: %s\n", window_id, *fullscreen, SDL_GetError());
|
|
894
902
|
}
|
|
895
903
|
|
|
904
|
+
int actual_flags = SDL_GetWindowFlags(window);
|
|
905
|
+
*fullscreen = actual_flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_FULLSCREEN_DESKTOP);
|
|
906
|
+
|
|
896
907
|
return nullptr;
|
|
897
908
|
}
|
|
898
909
|
|
|
899
910
|
ErrorMessage *
|
|
900
|
-
window_setResizable (int window_id, bool resizable)
|
|
911
|
+
window_setResizable (int window_id, bool * resizable)
|
|
901
912
|
{
|
|
902
913
|
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
903
914
|
if (window == nullptr) {
|
|
904
915
|
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
905
916
|
}
|
|
906
917
|
|
|
907
|
-
SDL_SetWindowResizable(window, resizable ? SDL_TRUE : SDL_FALSE);
|
|
918
|
+
SDL_SetWindowResizable(window, *resizable ? SDL_TRUE : SDL_FALSE);
|
|
919
|
+
|
|
920
|
+
int actual_flags = SDL_GetWindowFlags(window);
|
|
921
|
+
*resizable = actual_flags & SDL_WINDOW_RESIZABLE;
|
|
908
922
|
|
|
909
923
|
return nullptr;
|
|
910
924
|
}
|
|
911
925
|
|
|
912
926
|
ErrorMessage *
|
|
913
|
-
window_setBorderless (int window_id, bool borderless)
|
|
927
|
+
window_setBorderless (int window_id, bool * borderless)
|
|
914
928
|
{
|
|
915
929
|
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
916
930
|
if (window == nullptr) {
|
|
917
931
|
RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
|
|
918
932
|
}
|
|
919
933
|
|
|
920
|
-
SDL_SetWindowBordered(window, borderless ? SDL_FALSE : SDL_TRUE);
|
|
934
|
+
SDL_SetWindowBordered(window, *borderless ? SDL_FALSE : SDL_TRUE);
|
|
935
|
+
|
|
936
|
+
int actual_flags = SDL_GetWindowFlags(window);
|
|
937
|
+
*borderless = actual_flags & SDL_WINDOW_BORDERLESS;
|
|
921
938
|
|
|
922
939
|
return nullptr;
|
|
923
940
|
}
|
|
924
941
|
|
|
925
942
|
ErrorMessage *
|
|
926
|
-
window_setAcceleratedAndVsync (int window_id, bool accelerated, bool vsync)
|
|
943
|
+
window_setAcceleratedAndVsync (int window_id, bool * accelerated, bool * vsync)
|
|
927
944
|
{
|
|
928
945
|
SDL_Window * window = SDL_GetWindowFromID(window_id);
|
|
929
946
|
if (window == nullptr) {
|
package/src/native/sdl-helpers.h
CHANGED
|
@@ -50,21 +50,21 @@ ErrorMessage * window_create (
|
|
|
50
50
|
const char * title, int display,
|
|
51
51
|
int ** x, int ** y, int ** width, int ** height,
|
|
52
52
|
bool visible,
|
|
53
|
-
bool fullscreen,
|
|
54
|
-
bool resizable,
|
|
55
|
-
bool borderless,
|
|
56
|
-
bool accelerated,
|
|
57
|
-
bool vsync,
|
|
53
|
+
bool * fullscreen,
|
|
54
|
+
bool * resizable,
|
|
55
|
+
bool * borderless,
|
|
56
|
+
bool * accelerated,
|
|
57
|
+
bool * vsync,
|
|
58
58
|
bool opengl,
|
|
59
59
|
int * window_id, void ** native_pointer, int * native_pointer_size
|
|
60
60
|
);
|
|
61
61
|
ErrorMessage * window_setTitle (int window_id, const char * title);
|
|
62
62
|
ErrorMessage * window_setPosition (int window_id, int x, int y);
|
|
63
63
|
ErrorMessage * window_setSize (int window_id, int width, int height);
|
|
64
|
-
ErrorMessage * window_setFullscreen (int window_id, bool fullscreen);
|
|
65
|
-
ErrorMessage * window_setResizable (int window_id, bool resizable);
|
|
66
|
-
ErrorMessage * window_setBorderless (int window_id, bool borderless);
|
|
67
|
-
ErrorMessage * window_setAcceleratedAndVsync (int window_id, bool accelerated, bool vsync);
|
|
64
|
+
ErrorMessage * window_setFullscreen (int window_id, bool * fullscreen);
|
|
65
|
+
ErrorMessage * window_setResizable (int window_id, bool * resizable);
|
|
66
|
+
ErrorMessage * window_setBorderless (int window_id, bool * borderless);
|
|
67
|
+
ErrorMessage * window_setAcceleratedAndVsync (int window_id, bool * accelerated, bool * vsync);
|
|
68
68
|
ErrorMessage * window_focus (int window_id);
|
|
69
69
|
ErrorMessage * window_show (int window_id);
|
|
70
70
|
ErrorMessage * window_hide (int window_id);
|