Skip to content

Commit 6521d7e

Browse files
authored
Improve libglemu.js compile-time checks. NFC (#23876)
Also, remove the explicit dependency between glMatrixMode and GLEmulation. `GLEmulation` is always included when this file is used so this should not be necessary. I can't see exactly why this was originally added in 30bf9d7 but the corresponding test still passes without. Split out from #23855
1 parent c3d29d1 commit 6521d7e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/lib/libglemu.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
* SPDX-License-Identifier: MIT
55
*/
66

7+
assert(LEGACY_GL_EMULATION, 'libglemu.js should only be included with LEGACY_GL_EMULATION set')
8+
assert(!FULL_ES2, 'cannot emulate both ES2 and legacy GL');
9+
assert(!FULL_ES3, 'cannot emulate both ES3 and legacy GL');
10+
711
{{{
812
const copySigs = (func) => {
913
if (!RELOCATABLE) return '';
@@ -3616,7 +3620,7 @@ var LibraryGLEmulation = {
36163620

36173621
// OpenGL Immediate Mode matrix routines.
36183622
// Note that in the future we might make these available only in certain modes.
3619-
glMatrixMode__deps: ['$GL', '$GLImmediateSetup', '$GLEmulation'], // emulation is not strictly needed, this is a workaround
3623+
glMatrixMode__deps: ['$GL', '$GLImmediateSetup'],
36203624
glMatrixMode: (mode) => {
36213625
if (mode == 0x1700 /* GL_MODELVIEW */) {
36223626
GLImmediate.currentMatrix = 0/*m*/;
@@ -3948,14 +3952,8 @@ var LibraryGLEmulation = {
39483952
gluOrtho2D: (left, right, bottom, top) => _glOrtho(left, right, bottom, top, -1, 1),
39493953
};
39503954

3951-
// Legacy GL emulation
3952-
if (LEGACY_GL_EMULATION) {
3953-
extraLibraryFuncs.push('$GLEmulation');
3954-
}
3955+
extraLibraryFuncs.push('$GLEmulation');
39553956

39563957
recordGLProcAddressGet(LibraryGLEmulation);
39573958

39583959
addToLibrary(LibraryGLEmulation);
3959-
3960-
assert(!(FULL_ES2 && LEGACY_GL_EMULATION), 'cannot emulate both ES2 and legacy GL');
3961-
assert(!(FULL_ES3 && LEGACY_GL_EMULATION), 'cannot emulate both ES3 and legacy GL');

0 commit comments

Comments
 (0)