diff --git a/.circleci/config.yml b/.circleci/config.yml index dffff08b436fd..520a08d52a8c7 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 468fe487c6423..bc1af123e3303 100644 --- a/src/library_html5_webgl.js +++ b/src/library_html5_webgl.js @@ -30,12 +30,12 @@ var LibraryHtml5WebGL = { HEAP32[a+i] = 0; } - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.alpha }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}}>>2)] = - HEAP32[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault }}}>>2)] = 1; + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.alpha }}})] = + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.depth }}})] = + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.antialias }}})] = + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.premultipliedAlpha }}})] = + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.majorVersion }}})] = + HEAP8[a + ({{{ C_STRUCTS.EmscriptenWebGLContextAttributes.enableExtensionsByDefault }}})] = 1; #if PTHREADS // Default context initialization state (user can override): @@ -80,25 +80,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/float_tex.cpp b/test/float_tex.cpp index 6c14f5168cf3a..f0e426bd9d2b7 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; }