diff --git a/.circleci/config.yml b/.circleci/config.yml index dffff08b436f..520a08d52a8c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -817,6 +817,7 @@ jobs: browser64_4gb.test_audio_worklet* browser64_4gb.test_emscripten_log browser64_4gb.test_clientside_vertex_arrays_es3 + browser64_4gb.test_emscripten_animate_canvas_element_size* " test-browser-firefox: executor: bionic diff --git a/src/library_html5_webgl.js b/src/library_html5_webgl.js index 370e7b8a25b9..1cf2dedbc2d9 100644 --- a/src/library_html5_webgl.js +++ b/src/library_html5_webgl.js @@ -55,25 +55,25 @@ var LibraryHtml5WebGL = { #if ASSERTIONS assert(attributes); #endif - var a = attributes >> 2; - var powerPreference = HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.powerPreference }}}>>2)]; + var powerPreference = {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.powerPreference, 'i32') }}}; var contextAttributes = { - 'alpha': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.alpha }}}>>2)], - 'depth': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)], - 'stencil': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.stencil }}}>>2)], - 'antialias': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)], - 'premultipliedAlpha': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)], - 'preserveDrawingBuffer': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer }}}>>2)], + 'alpha': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.alpha, 'i32') }}}, + 'depth': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.depth, 'i32') }}}, + 'stencil': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.stencil, 'i32') }}}, + 'antialias': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.antialias, 'i32') }}}, + 'premultipliedAlpha': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha, 'i32') }}}, + 'preserveDrawingBuffer': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.preserveDrawingBuffer, 'i32') }}}, 'powerPreference': emscripten_webgl_power_preferences[powerPreference], - 'failIfMajorPerformanceCaveat': !!HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.failIfMajorPerformanceCaveat }}}>>2)], + 'failIfMajorPerformanceCaveat': !!{{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.failIfMajorPerformanceCaveat, 'i32') }}}, // The following are not predefined WebGL context attributes in the WebGL specification, so the property names can be minified by Closure. - majorVersion: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)], - minorVersion: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.minorVersion }}}>>2)], - enableExtensionsByDefault: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault }}}>>2)], - explicitSwapControl: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.explicitSwapControl }}}>>2)], - proxyContextToMainThread: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.proxyContextToMainThread }}}>>2)], - renderViaOffscreenBackBuffer: HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer }}}>>2)] + majorVersion: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion, 'i32') }}}, + minorVersion: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.minorVersion, 'i32') }}}, + enableExtensionsByDefault: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault, 'i32') }}}, + explicitSwapControl: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.explicitSwapControl, 'i32') }}}, + proxyContextToMainThread: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.proxyContextToMainThread, 'i32') }}}, + renderViaOffscreenBackBuffer: {{{ makeGetValue('attributes', C_STRUCTS.EmscriptenWebGLContextAttributes.renderViaOffscreenBackBuffer, 'i32') }}} }; + err(contextAttributes); var canvas = findCanvasEventTarget(target); diff --git a/test/code_size/hello_webgl2_wasm.json b/test/code_size/hello_webgl2_wasm.json index ebe59e5d67b2..fdcf2fc7955e 100644 --- a/test/code_size/hello_webgl2_wasm.json +++ b/test/code_size/hello_webgl2_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4593, - "a.js.gz": 2369, + "a.js": 4654, + "a.js.gz": 2378, "a.wasm": 10451, "a.wasm.gz": 6724, - "total": 15613, - "total_gz": 9472 + "total": 15674, + "total_gz": 9481 } diff --git a/test/code_size/hello_webgl2_wasm2js.json b/test/code_size/hello_webgl2_wasm2js.json index c643b7051985..fca0b76b9729 100644 --- a/test/code_size/hello_webgl2_wasm2js.json +++ b/test/code_size/hello_webgl2_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 17937, - "a.js.gz": 8074, + "a.js": 17997, + "a.js.gz": 8093, "a.mem": 3123, "a.mem.gz": 2693, - "total": 21627, - "total_gz": 11146 + "total": 21687, + "total_gz": 11165 } diff --git a/test/code_size/hello_webgl_wasm.json b/test/code_size/hello_webgl_wasm.json index 5e1cea0d8e84..d247374d2b36 100644 --- a/test/code_size/hello_webgl_wasm.json +++ b/test/code_size/hello_webgl_wasm.json @@ -1,10 +1,10 @@ { "a.html": 569, "a.html.gz": 379, - "a.js": 4080, - "a.js.gz": 2198, + "a.js": 4140, + "a.js.gz": 2206, "a.wasm": 10451, "a.wasm.gz": 6724, - "total": 15100, - "total_gz": 9301 + "total": 15160, + "total_gz": 9309 } diff --git a/test/code_size/hello_webgl_wasm2js.json b/test/code_size/hello_webgl_wasm2js.json index 67294a8bfd64..a5220393cb83 100644 --- a/test/code_size/hello_webgl_wasm2js.json +++ b/test/code_size/hello_webgl_wasm2js.json @@ -1,10 +1,10 @@ { "a.html": 567, "a.html.gz": 379, - "a.js": 17415, - "a.js.gz": 7891, + "a.js": 17475, + "a.js.gz": 7911, "a.mem": 3123, "a.mem.gz": 2693, - "total": 21105, - "total_gz": 10963 + "total": 21165, + "total_gz": 10983 } diff --git a/test/float_tex.cpp b/test/float_tex.cpp index 6c14f5168cf3..f0e426bd9d2b 100644 --- a/test/float_tex.cpp +++ b/test/float_tex.cpp @@ -9,10 +9,9 @@ #include #include #include -extern "C" { #include #include -} + static const char vertex_shader[] = "#ifdef GL_ES\n" "precision lowp float;\n" @@ -44,6 +43,7 @@ static const char fragment_shader[] = "}\n" "if ( dst > 0.5) discard;\n" "}"; + struct NodeInfo { //structure that we want to transmit to our shaders float x; float y; @@ -55,8 +55,9 @@ GLuint nodeSamplerLocation; //shader sampler address GLuint indicesAttributeLocation; //shader attribute address GLuint indicesVBO; //Vertex Buffer Object Id; const int nbNodes = 512; -NodeInfo * data = new NodeInfo[nbNodes]; //our data that will be transmitted using float texture. +NodeInfo data[nbNodes]; //our data that will be transmitted using float texture. double alpha = 0; //use to make a simple funny effect; + static void updateFloatTexture() { int count = 0; for (float x=0; x < nbNodes; ++x ) { @@ -79,7 +80,9 @@ static void updateFloatTexture() { glBindTexture(GL_TEXTURE_2D, 0); alpha -= 0.001; } + static void glut_draw_callback(void) { + printf("glut_draw_callback\n"); glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); @@ -96,6 +99,7 @@ static void glut_draw_callback(void) { glDrawArrays(GL_POINTS, 0, nbNodes); glutSwapBuffers(); } + GLuint createShader(const char source[], int type) { GLint status; char msg[512]; @@ -110,6 +114,7 @@ GLuint createShader(const char source[], int type) { assert(status == GL_TRUE); return shader; } + static void gl_init(void) { GLuint program = glCreateProgram(); glAttachShader(program, createShader(vertex_shader , GL_VERTEX_SHADER)); @@ -145,6 +150,7 @@ static void gl_init(void) { glEnable(GL_POINT_SPRITE); #endif } + int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(640, 480); @@ -153,6 +159,7 @@ int main(int argc, char *argv[]) { /* Set up glut callback functions */ glutDisplayFunc(glut_draw_callback ); gl_init(); + printf("done setup\n"); glutMainLoop(); return 0; }