aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-08-15 10:52:03 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-08-15 11:26:53 -0700
commit19047555b54a8190a927e77f2d1c73410ad4fd0a (patch)
tree008c65eac9a813394a640a4ba376f02b9dbb5b18 /src
parentced412e4d5a26ad59a007b9e27d02c2e9ed99d15 (diff)
make legacy gl emulation an opt-in option, LEGACY_GL_EMULATION
Diffstat (limited to 'src')
-rw-r--r--src/library_gl.js40
-rw-r--r--src/settings.js5
2 files changed, 34 insertions, 11 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 8c724245..17595021 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -1285,7 +1285,7 @@ var LibraryGL = {
return Module.ctx.isFramebuffer(fb);
},
-#if DISABLE_GL_EMULATION == 0
+#if LEGACY_GL_EMULATION
// GL emulation: provides misc. functionality not present in OpenGL ES 2.0 or WebGL
@@ -1323,7 +1323,7 @@ var LibraryGL = {
GLEmulation.fogColor = new Float32Array(4);
// Add some emulation workarounds
- Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work. (If you do not want this, build with -s DISABLE_GL_EMULATION=1)');
+ Module.printErr('WARNING: using emscripten GL emulation. This is a collection of limited workarounds, do not expect it to work.');
#if GL_UNSAFE_OPTS == 0
Module.printErr('WARNING: using emscripten GL emulation unsafe opts. If weirdness happens, try -s GL_UNSAFE_OPTS=0');
#endif
@@ -4202,7 +4202,31 @@ var LibraryGL = {
glBindVertexArrayOES: 'glBindVertexArray',
glFramebufferTexture2DOES: 'glFramebufferTexture2D',
-#endif // DISABLE_GL_EMULATION == 0
+#else // LEGACY_GL_EMULATION
+
+ // Warn if code tries to use various emulation stuff, when emulation is disabled
+ glVertexPointer__deps: [function() {
+ error('Legacy GL function (glVertexPointer) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.');
+ }],
+ glVertexPointer: function(){},
+ glGenVertexArrays__deps: [function() {
+ error('Legacy GL function (glGenVertexArrays) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.');
+ }],
+ glGenVertexArrays: function(){},
+ glMatrixMode__deps: [function() {
+ error('Legacy GL function (glMatrixMode) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.');
+ }],
+ glMatrixMode: function(){},
+ glBegin__deps: [function() {
+ error('Legacy GL function (glBegin) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.');
+ }],
+ glBegin: function(){},
+ glLoadIdentity__deps: [function() {
+ error('Legacy GL function (glLoadIdentity) called. You need to compile with -s LEGACY_GL_EMULATION=1 to enable legacy GL emulation.');
+ }],
+ glLoadIdentity: function(){},
+
+#endif // LEGACY_GL_EMULATION
// GLU
@@ -4438,7 +4462,7 @@ var LibraryGL = {
autoAddDeps(LibraryGL, '$GL');
-if (!DISABLE_GL_EMULATION) {
+if (LEGACY_GL_EMULATION) {
// Emulation requires everything else, potentially
LibraryGL.$GLEmulation__deps = LibraryGL.$GLEmulation__deps.slice(0); // the __deps object is shared
var glFuncs = [];
@@ -4455,11 +4479,11 @@ if (!DISABLE_GL_EMULATION) {
}
});
- if (FORCE_GL_EMULATION) {
- LibraryGL.glDrawElements__deps = LibraryGL.glDrawElements__deps.concat('$GLEmulation');
- LibraryGL.glDrawArrays__deps = LibraryGL.glDrawArrays__deps.concat('$GLEmulation');
- }
+ LibraryGL.glDrawElements__deps = LibraryGL.glDrawElements__deps.concat('$GLEmulation');
+ LibraryGL.glDrawArrays__deps = LibraryGL.glDrawArrays__deps.concat('$GLEmulation');
}
mergeInto(LibraryManager.library, LibraryGL);
+assert(!(FULL_ES2 && LEGACY_GL_EMULATION), 'cannot emulate both ES2 and legacy GL');
+
diff --git a/src/settings.js b/src/settings.js
index 3ecac040..8757f7b9 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -191,9 +191,8 @@ var GL_TESTING = 0; // When enabled, sets preserveDrawingBuffer in the context,
var GL_MAX_TEMP_BUFFER_SIZE = 2097152; // How large GL emulation temp buffers are
var GL_UNSAFE_OPTS = 1; // Enables some potentially-unsafe optimizations in GL emulation code
var FULL_ES2 = 0; // Forces support for all GLES2 features, not just the WebGL-friendly subset.
-var FORCE_GL_EMULATION = 0; // Forces inclusion of full GL emulation code.
-var DISABLE_GL_EMULATION = 0; // Disable inclusion of full GL emulation code. Useful when you don't want emulation
- // but do need INCLUDE_FULL_LIBRARY or MAIN_MODULE.
+var LEGACY_GL_EMULATION = 0; // Includes code to emulate various desktop GL features. Incomplete but useful
+ // in some cases, see https://github.com/kripken/emscripten/wiki/OpenGL-support
var STB_IMAGE = 0; // Enables building of stb-image, a tiny public-domain library for decoding images, allowing
// decoding of images without using the browser's built-in decoders. The benefit is that this