aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js7
-rw-r--r--src/library_browser.js2
-rw-r--r--src/library_gl.js49
-rw-r--r--src/library_glut.js9
-rw-r--r--src/library_openal.js8
5 files changed, 53 insertions, 22 deletions
diff --git a/src/library.js b/src/library.js
index 501f766c..31f531e9 100644
--- a/src/library.js
+++ b/src/library.js
@@ -4164,6 +4164,11 @@ LibraryManager.library = {
},
// ==========================================================================
+ // GCC/LLVM specifics
+ // ==========================================================================
+ __builtin_prefetch: function(){},
+
+ // ==========================================================================
// LLVM specifics
// ==========================================================================
@@ -7330,6 +7335,7 @@ LibraryManager.library = {
// we're generating fake IP addresses with lookup_name that we can
// resolve later on with lookup_addr.
// We do the aliasing in 172.29.*.*, giving us 65536 possibilities.
+ $DNS__deps: ['_inet_pton4_raw', '_inet_pton6_raw'],
$DNS: {
address_map: {
id: 1,
@@ -7337,7 +7343,6 @@ LibraryManager.library = {
names: {}
},
- lookup_name__deps: ['_inet_pton4_raw', '_inet_pton6_raw'],
lookup_name: function (name) {
// If the name is already a valid ipv4 / ipv6 address, don't generate a fake one.
var res = __inet_pton4_raw(name);
diff --git a/src/library_browser.js b/src/library_browser.js
index b70dbc84..39a1c55d 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -359,7 +359,7 @@ mergeInto(LibraryManager.library, {
canvas.requestFullScreen();
},
- requestAnimationFrame: function(func) {
+ requestAnimationFrame: function requestAnimationFrame(func) {
if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js)
setTimeout(func, 1000/60);
} else {
diff --git a/src/library_gl.js b/src/library_gl.js
index 7074f844..ecb72f0f 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -11,6 +11,7 @@ var LibraryGL = {
#endif
counter: 1, // 0 is reserved as 'null' in gl
+ lastError: 0,
buffers: [],
programs: [],
framebuffers: [],
@@ -51,6 +52,13 @@ var LibraryGL = {
Browser.moduleContextCreatedCallbacks.push(GL.initExtensions);
},
+ // Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error
+ // is remembered, and subsequent errors are discarded until the user has cleared the stored error by a call to glGetError().
+ recordError: function recordError(errorCode) {
+ if (!GL.lastError) {
+ GL.lastError = errorCode;
+ }
+ },
// Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later.
getNewId: function(table) {
var ret = GL.counter++;
@@ -277,7 +285,7 @@ var LibraryGL = {
},
#if FULL_ES2
- calcBufLength: function(size, type, stride, count) {
+ calcBufLength: function calcBufLength(size, type, stride, count) {
if (stride > 0) {
return count * stride; // XXXvlad this is not exactly correct I don't think
}
@@ -287,7 +295,7 @@ var LibraryGL = {
usedTempBuffers: [],
- preDrawHandleClientVertexAttribBindings: function(count) {
+ preDrawHandleClientVertexAttribBindings: function preDrawHandleClientVertexAttribBindings(count) {
GL.resetBufferBinding = false;
var used = GL.usedTempBuffers;
@@ -321,7 +329,7 @@ var LibraryGL = {
}
},
- postDrawHandleClientVertexAttribBindings: function() {
+ postDrawHandleClientVertexAttribBindings: function postDrawHandleClientVertexAttribBindings() {
if (GL.resetBufferBinding) {
Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, GL.buffers[GL.currArrayBuffer]);
}
@@ -2123,9 +2131,6 @@ var LibraryGL = {
glGetShaderPrecisionFormat__sig: 'v',
glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' },
- glShaderBinary__sig: 'v',
- glShaderBinary: function() { throw 'glShaderBinary: TODO' },
-
glDeleteObject__sig: 'vi',
glDeleteObject: function(id) {
if (GL.programs[id]) {
@@ -2137,11 +2142,6 @@ var LibraryGL = {
}
},
- glReleaseShaderCompiler__sig: 'v',
- glReleaseShaderCompiler: function() {
- // NOP (as allowed by GLES 2.0 spec)
- },
-
glGetObjectParameteriv__sig: 'viii',
glGetObjectParameteriv: function(id, type, result) {
if (GL.programs[id]) {
@@ -4618,6 +4618,30 @@ var LibraryGL = {
#endif
},
+ glShaderBinary__sig: 'v',
+ glShaderBinary: function() {
+ GL.recordError(0x0500/*GL_INVALID_ENUM*/);
+#if GL_ASSERTIONS
+ Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail.");
+#endif
+ },
+
+ glReleaseShaderCompiler__sig: 'v',
+ glReleaseShaderCompiler: function() {
+ // NOP (as allowed by GLES 2.0 spec)
+ },
+
+ glGetError__sig: 'i',
+ glGetError: function() {
+ // First return any GL error generated by the emscripten library_gl.js interop layer.
+ if (GL.lastError) {
+ var error = GL.lastError;
+ GL.lastError = 0/*GL_NO_ERROR*/;
+ return error;
+ } else { // If there were none, return the GL error from the browser GL context.
+ return Module.ctx.getError();
+ }
+ },
// signatures of simple pass-through functions, see later
glActiveTexture__sig: 'vi',
@@ -4651,14 +4675,13 @@ var LibraryGL = {
glFlush__sig: 'v',
glClearColor__sig: 'viiii',
glIsEnabled__sig: 'ii',
- glGetError__sig: 'i',
glFrontFace__sig: 'vi',
glSampleCoverage__sig: 'vi',
};
// Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name
-[[0, 'getError* finish flush'],
+[[0, 'finish flush'],
[1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'],
[2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'],
[3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'],
diff --git a/src/library_glut.js b/src/library_glut.js
index 5e303fd2..ba4d75ab 100644
--- a/src/library_glut.js
+++ b/src/library_glut.js
@@ -59,6 +59,9 @@ var LibraryGLUT = {
getSpecialKey: function(keycode) {
var key = null;
switch (keycode) {
+ case 8: key = 120 /* backspace */; break;
+ case 46: key = 111 /* delete */; break;
+
case 0x70 /*DOM_VK_F1*/: key = 1 /* GLUT_KEY_F1 */; break;
case 0x71 /*DOM_VK_F2*/: key = 2 /* GLUT_KEY_F2 */; break;
case 0x72 /*DOM_VK_F3*/: key = 3 /* GLUT_KEY_F3 */; break;
@@ -228,14 +231,14 @@ var LibraryGLUT = {
if (delta < 0) {
button = 4; // wheel down
}
-
+
if (GLUT.mouseFunc) {
event.preventDefault();
GLUT.saveModifiers(event);
Runtime.dynCall('viiii', GLUT.mouseFunc, [button, 0/*GLUT_DOWN*/, Browser.mouseX, Browser.mouseY]);
}
},
-
+
// TODO add fullscreen API ala:
// http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/
onFullScreenEventChange: function(event) {
@@ -304,7 +307,7 @@ var LibraryGLUT = {
// Firefox
window.addEventListener("DOMMouseScroll", GLUT.onMouseWheel, true);
}
-
+
Browser.resizeListeners.push(function(width, height) {
if (GLUT.reshapeFunc) {
Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]);
diff --git a/src/library_openal.js b/src/library_openal.js
index e8a2e223..eb152f62 100644
--- a/src/library_openal.js
+++ b/src/library_openal.js
@@ -8,13 +8,13 @@ var LibraryOpenAL = {
QUEUE_INTERVAL: 25,
QUEUE_LOOKAHEAD: 100,
- updateSources: function(context) {
+ updateSources: function updateSources(context) {
for (var i = 0; i < context.src.length; i++) {
AL.updateSource(context.src[i]);
}
},
- updateSource: function(src) {
+ updateSource: function updateSource(src) {
#if OPENAL_DEBUG
var idx = AL.currentContext.src.indexOf(src);
#endif
@@ -65,7 +65,7 @@ var LibraryOpenAL = {
}
},
- setSourceState: function(src, state) {
+ setSourceState: function setSourceState(src, state) {
#if OPENAL_DEBUG
var idx = AL.currentContext.src.indexOf(src);
#endif
@@ -119,7 +119,7 @@ var LibraryOpenAL = {
}
},
- stopSourceQueue: function(src) {
+ stopSourceQueue: function stopSourceQueue(src) {
for (var i = 0; i < src.queue.length; i++) {
var entry = src.queue[i];
if (entry.src) {