aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library_gl.js14
-rw-r--r--tests/gl_vertex_buffer.c9
-rw-r--r--tests/test_browser.py2
3 files changed, 19 insertions, 6 deletions
diff --git a/src/library_gl.js b/src/library_gl.js
index 5184f4fd..16ea5531 100644
--- a/src/library_gl.js
+++ b/src/library_gl.js
@@ -657,6 +657,20 @@ var LibraryGL = {
glBufferData__sig: 'viiii',
glBufferData: function(target, size, data, usage) {
+ switch (usage) { // fix usages, WebGL only has *_DRAW
+ case 0x88E1: // GL_STREAM_READ
+ case 0x88E2: // GL_STREAM_COPY
+ usage = 0x88E0; // GL_STREAM_DRAW
+ break;
+ case 0x88E5: // GL_STATIC_READ
+ case 0x88E6: // GL_STATIC_COPY
+ usage = 0x88E4; // GL_STATIC_DRAW
+ break;
+ case 0x88E9: // GL_DYNAMIC_READ
+ case 0x88EA: // GL_DYNAMIC_COPY
+ usage = 0x88E8; // GL_DYNAMIC_DRAW
+ break;
+ }
Module.ctx.bufferData(target, HEAPU8.subarray(data, data+size), usage);
},
diff --git a/tests/gl_vertex_buffer.c b/tests/gl_vertex_buffer.c
index 931db618..6b695462 100644
--- a/tests/gl_vertex_buffer.c
+++ b/tests/gl_vertex_buffer.c
@@ -137,7 +137,7 @@ int main(int argc, char *argv[])
// bind to it
glBindBuffer(GL_ARRAY_BUFFER, vbo);
// send it to gl
- glBufferData(GL_ARRAY_BUFFER, sizeof(vertices2), vertices2, GL_STATIC_READ);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(vertices2), vertices2, GL_STATIC_READ); // GL_STATIC_READ is not in WebGL!
// unbind from it
glBindBuffer(GL_ARRAY_BUFFER, 0);
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
- // TEST 1
+ // TEST 1 - clientside data
glVertexPointer(2, GL_FLOAT, sizeof(Vertex), vertices);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), &vertices[0].color);
@@ -166,9 +166,8 @@ int main(int argc, char *argv[])
- // TEST 2
+ // TEST 2 - bind to array buffer, gl*Pointer calls are offsets into the buffer, which was previously uploaded to
-// bind to it again
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glVertexPointer(2, GL_FLOAT, sizeof(Vertex), 0);
@@ -187,7 +186,7 @@ int main(int argc, char *argv[])
#if !EMSCRIPTEN
// Wait for 3 seconds to give us a chance to see the image
- SDL_Delay(6000);
+ SDL_Delay(3000);
#endif
SDL_Quit();
diff --git a/tests/test_browser.py b/tests/test_browser.py
index 10b048a0..3ac640f1 100644
--- a/tests/test_browser.py
+++ b/tests/test_browser.py
@@ -1211,7 +1211,7 @@ If manually bisecting:
self.btest('gl_vertex_buffer_pre.c', reference='gl_vertex_buffer_pre.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'])
def test_gl_vertex_buffer(self):
- self.btest('gl_vertex_buffer.c', reference='gl_vertex_buffer.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'])
+ self.btest('gl_vertex_buffer.c', reference='gl_vertex_buffer.png', args=['-s', 'GL_UNSAFE_OPTS=0', '-s', 'LEGACY_GL_EMULATION=1'], reference_slack=1)
def test_matrix_identity(self):
self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840'], args=['-s', 'LEGACY_GL_EMULATION=1'])