15
15
* value of 62006. (multiple creations silently return the same surface)
16
16
*/
17
17
18
+ { { {
19
+ // Magic ID for Emscripten 'default display'
20
+ globalThis . eglDefaultDisplay = 62000 ;
21
+ // Magic ID for the only EGLConfig supported by Emscripten
22
+ globalThis . eglDefaultConfig = 62002 ;
23
+ // Magic ID for Emscripten EGLContext
24
+ globalThis . eglDefaultContext = 62004 ;
25
+ } } }
26
+
18
27
var LibraryEGL = {
19
28
$EGL__deps : [ '$Browser' ] ,
20
29
$EGL : {
@@ -39,7 +48,7 @@ var LibraryEGL = {
39
48
} ,
40
49
41
50
chooseConfig ( display , attribList , config , config_size , numConfigs ) {
42
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
51
+ if ( display != { { { eglDefaultDisplay } } } ) {
43
52
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
44
53
return 0 ;
45
54
}
@@ -81,7 +90,7 @@ var LibraryEGL = {
81
90
{ { { makeSetValue ( 'numConfigs' , '0' , '1' , 'i32' ) } } } ; // Total number of supported configs: 1.
82
91
}
83
92
if ( config && config_size > 0 ) {
84
- { { { makeSetValue ( 'config' , '0' , '62002' /* Magic ID for the only EGLConfig supported by Emscripten */ , '*' ) } } } ;
93
+ { { { makeSetValue ( 'config' , '0' , eglDefaultConfig /* Magic ID for the only EGLConfig supported by Emscripten */ , '*' ) } } } ;
85
94
}
86
95
87
96
EGL . setErrorCode ( 0x3000 /* EGL_SUCCESS */ ) ;
@@ -101,7 +110,7 @@ var LibraryEGL = {
101
110
// Therefore, be lax and allow anything to be passed in, and return the magic handle to our default EGLDisplay object.
102
111
103
112
// if (nativeDisplayType == 0 /* EGL_DEFAULT_DISPLAY */) {
104
- return 62000 ; // Magic ID for Emscripten 'default display'
113
+ return { { { eglDefaultDisplay } } } ;
105
114
// }
106
115
// else
107
116
// return 0; // EGL_NO_DISPLAY
@@ -110,7 +119,7 @@ var LibraryEGL = {
110
119
// EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor);
111
120
eglInitialize__proxy : 'sync' ,
112
121
eglInitialize : ( display , majorVersion , minorVersion ) = > {
113
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
122
+ if ( display != { { { eglDefaultDisplay } } } ) {
114
123
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
115
124
return 0 ;
116
125
}
@@ -128,7 +137,7 @@ var LibraryEGL = {
128
137
// EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy);
129
138
eglTerminate__proxy: 'sync' ,
130
139
eglTerminate : ( display ) => {
131
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
140
+ if ( display != { { { eglDefaultDisplay } } } ) {
132
141
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
133
142
return 0 ;
134
143
}
@@ -155,11 +164,11 @@ var LibraryEGL = {
155
164
// EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
156
165
eglGetConfigAttrib__proxy : 'sync' ,
157
166
eglGetConfigAttrib : ( display , config , attribute , value ) = > {
158
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
167
+ if ( display != { { { eglDefaultDisplay } } } ) {
159
168
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
160
169
return 0 ;
161
170
}
162
- if ( config != 62002 /* Magic ID for the only EGLConfig supported by Emscripten */ ) {
171
+ if ( config != { { { eglDefaultConfig } } } ) {
163
172
EGL . setErrorCode ( 0x3005 /* EGL_BAD_CONFIG */ ) ;
164
173
return 0 ;
165
174
}
@@ -195,7 +204,7 @@ var LibraryEGL = {
195
204
{ { { makeSetValue ( 'value' , '0' , '0x3038' /* EGL_NONE */ , 'i32' ) } } } ;
196
205
return 1 ;
197
206
case 0x3028 : // EGL_CONFIG_ID
198
- { { { makeSetValue ( 'value' , '0' , '62002' /* Magic ID for the only EGLConfig supported by Emscripten */ , 'i32' ) } } } ;
207
+ { { { makeSetValue ( 'value' , '0' , eglDefaultConfig , 'i32' ) } } } ;
199
208
return 1 ;
200
209
case 0x3029 : // EGL_LEVEL
201
210
{ { { makeSetValue ( 'value' , '0' , '0' /* Z order/depth layer for this level. Not applicable for Emscripten. */ , 'i32' ) } } } ;
@@ -272,11 +281,11 @@ var LibraryEGL = {
272
281
// EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
273
282
eglCreateWindowSurface__proxy: 'sync' ,
274
283
eglCreateWindowSurface : ( display , config , win , attrib_list ) = > {
275
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
284
+ if ( display != { { { eglDefaultDisplay } } } ) {
276
285
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
277
286
return 0 ;
278
287
}
279
- if ( config != 62002 /* Magic ID for the only EGLConfig supported by Emscripten */ ) {
288
+ if ( config != { { { eglDefaultConfig } } } ) {
280
289
EGL . setErrorCode ( 0x3005 /* EGL_BAD_CONFIG */ ) ;
281
290
return 0 ;
282
291
}
@@ -291,7 +300,7 @@ var LibraryEGL = {
291
300
// EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay display, EGLSurface surface);
292
301
eglDestroySurface__proxy: 'sync' ,
293
302
eglDestroySurface : ( display , surface ) => {
294
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
303
+ if ( display != { { { eglDefaultDisplay } } } ) {
295
304
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
296
305
return 0 ;
297
306
}
@@ -314,7 +323,7 @@ var LibraryEGL = {
314
323
// EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
315
324
eglCreateContext__proxy : 'sync' ,
316
325
eglCreateContext : ( display , config , hmm , contextAttribs ) = > {
317
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
326
+ if ( display != { { { eglDefaultDisplay } } } ) {
318
327
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
319
328
return 0 ;
320
329
}
@@ -366,7 +375,7 @@ var LibraryEGL = {
366
375
367
376
// Note: This function only creates a context, but it shall not make it active.
368
377
GL . makeContextCurrent ( null ) ;
369
- return 62004 ; // Magic ID for Emscripten EGLContext
378
+ return { { { eglDefaultContext } } } ;
370
379
} else {
371
380
EGL . setErrorCode ( 0x3009 /* EGL_BAD_MATCH */ ) ; // By the EGL 1.4 spec, an implementation that does not support GLES2 (WebGL in this case), this error code is set.
372
381
return 0 ; /* EGL_NO_CONTEXT */
@@ -378,11 +387,11 @@ var LibraryEGL = {
378
387
// EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext context);
379
388
eglDestroyContext__proxy : 'sync' ,
380
389
eglDestroyContext : ( display , context ) = > {
381
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
390
+ if ( display != { { { eglDefaultDisplay } } } ) {
382
391
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
383
392
return 0 ;
384
393
}
385
- if ( context != 62004 /* Magic ID for Emscripten EGLContext */ ) {
394
+ if ( context != { { { eglDefaultContext } } } ) {
386
395
EGL . setErrorCode ( 0x3006 /* EGL_BAD_CONTEXT */ ) ;
387
396
return 0 ;
388
397
}
@@ -398,7 +407,7 @@ var LibraryEGL = {
398
407
// EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
399
408
eglQuerySurface__proxy: 'sync' ,
400
409
eglQuerySurface : ( display , surface , attribute , value ) = > {
401
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
410
+ if ( display != { { { eglDefaultDisplay } } } ) {
402
411
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
403
412
return 0 ;
404
413
}
@@ -413,7 +422,7 @@ var LibraryEGL = {
413
422
EGL . setErrorCode ( 0x3000 /* EGL_SUCCESS */ ) ;
414
423
switch ( attribute ) {
415
424
case 0x3028 : // EGL_CONFIG_ID
416
- { { { makeSetValue ( 'value' , '0' , '62002' /* A magic value for the only EGLConfig configuration ID supported by Emscripten. */ , 'i32' ) } } } ;
425
+ { { { makeSetValue ( 'value' , '0' , eglDefaultConfig , 'i32' ) } } } ;
417
426
return 1 ;
418
427
case 0x3058 : // EGL_LARGEST_PBUFFER
419
428
// Odd EGL API: If surface is not a pbuffer surface, 'value' should not be written to. It's not specified as an error, so true should(?) be returned.
@@ -464,12 +473,12 @@ var LibraryEGL = {
464
473
// EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
465
474
eglQueryContext__proxy: 'sync' ,
466
475
eglQueryContext : ( display , context , attribute , value ) = > {
467
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
476
+ if ( display != { { { eglDefaultDisplay } } } ) {
468
477
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
469
478
return 0 ;
470
479
}
471
480
//\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy.
472
- if ( context != 62004 /* Magic ID for Emscripten EGLContext */ ) {
481
+ if ( context != { { { eglDefaultContext } } } ) {
473
482
EGL . setErrorCode ( 0x3006 /* EGL_BAD_CONTEXT */ ) ;
474
483
return 0 ;
475
484
}
@@ -481,7 +490,7 @@ var LibraryEGL = {
481
490
EGL . setErrorCode ( 0x3000 /* EGL_SUCCESS */ ) ;
482
491
switch ( attribute ) {
483
492
case 0x3028 : // EGL_CONFIG_ID
484
- { { { makeSetValue ( 'value' , '0' , '62002' /* A magic value for the only EGLConfig configuration ID supported by Emscripten. */ , 'i32' ) } } } ;
493
+ { { { makeSetValue ( 'value' , '0' , eglDefaultConfig , 'i32' ) } } } ;
485
494
return 1 ;
486
495
case 0x3097 : // EGL_CONTEXT_CLIENT_TYPE
487
496
{ { { makeSetValue ( 'value' , '0' , '0x30A0' /* EGL_OPENGL_ES_API */ , 'i32' ) } } } ;
@@ -502,15 +511,13 @@ var LibraryEGL = {
502
511
503
512
// EGLAPI EGLint EGLAPIENTRY eglGetError(void);
504
513
eglGetError__proxy: 'sync' ,
505
- eglGetError : ( ) = > {
506
- return EGL . errorCode ;
507
- } ,
514
+ eglGetError : ( ) => EGL . errorCode ,
508
515
509
516
// EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name);
510
517
eglQueryString__deps : [ '$stringToNewUTF8' ] ,
511
518
eglQueryString__proxy : 'sync' ,
512
519
eglQueryString : ( display , name ) => {
513
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
520
+ if ( display != { { { eglDefaultDisplay } } } ) {
514
521
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
515
522
return 0 ;
516
523
}
@@ -572,7 +579,7 @@ var LibraryEGL = {
572
579
eglSwapInterval__deps : [ 'emscripten_set_main_loop_timing' ] ,
573
580
eglSwapInterval__proxy : 'sync' ,
574
581
eglSwapInterval : ( display , interval ) => {
575
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
582
+ if ( display != { { { eglDefaultDisplay } } } ) {
576
583
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
577
584
return 0 ;
578
585
}
@@ -587,12 +594,12 @@ var LibraryEGL = {
587
594
eglMakeCurrent__deps: [ '$GL' ] ,
588
595
eglMakeCurrent__proxy : 'sync' ,
589
596
eglMakeCurrent : ( display , draw , read , context ) = > {
590
- if ( display != 62000 /* Magic ID for Emscripten 'default display' */ ) {
597
+ if ( display != { { { eglDefaultDisplay } } } ) {
591
598
EGL . setErrorCode ( 0x3008 /* EGL_BAD_DISPLAY */ ) ;
592
599
return 0 /* EGL_FALSE */ ;
593
600
}
594
601
//\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy.
595
- if ( context != 0 && context != 62004 /* Magic ID for Emscripten EGLContext */ ) {
602
+ if ( context != 0 && context != { { { eglDefaultContext } } } ) {
596
603
EGL . setErrorCode ( 0x3006 /* EGL_BAD_CONTEXT */ ) ;
597
604
return 0 ;
598
605
}
@@ -612,9 +619,7 @@ var LibraryEGL = {
612
619
613
620
// EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void);
614
621
eglGetCurrentContext__proxy: 'sync' ,
615
- eglGetCurrentContext : ( ) = > {
616
- return EGL . currentContext ;
617
- } ,
622
+ eglGetCurrentContext : ( ) => EGL . currentContext ,
618
623
619
624
// EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw);
620
625
eglGetCurrentSurface__proxy : 'sync' ,
@@ -631,9 +636,7 @@ var LibraryEGL = {
631
636
632
637
// EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void);
633
638
eglGetCurrentDisplay__proxy : 'sync' ,
634
- eglGetCurrentDisplay : ( ) = > {
635
- return EGL . currentContext ? 62000 /* Magic ID for Emscripten 'default display' */ : 0 ;
636
- } ,
639
+ eglGetCurrentDisplay : ( ) = > EGL . currentContext ? { { { eglDefaultDisplay } } } : 0 ,
637
640
638
641
// EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface);
639
642
eglSwapBuffers__proxy : 'sync' ,
0 commit comments