diff --git a/src/library_gl.js b/src/library_gl.js index 66a9cc99c8f3a..069d534359d6b 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -549,6 +549,11 @@ var LibraryGL = { }, #if OFFSCREEN_FRAMEBUFFER + enableOffscreenFramebufferAttributes: function(webGLContextAttributes) { + webGLContextAttributes.renderViaOffscreenBackBuffer = true; + webGLContextAttributes.preserveDrawingBuffer = true; + }, + // If WebGL is being proxied from a pthread to the main thread, we can't directly render to the WebGL default back buffer // because of WebGL's implicit swap behavior. Therefore in such modes, create an offscreen render target surface to // which rendering is performed to, and finally flipped to the main screen. diff --git a/src/library_glfw.js b/src/library_glfw.js index 683e902d20577..8393d087d177a 100644 --- a/src/library_glfw.js +++ b/src/library_glfw.js @@ -998,8 +998,7 @@ var LibraryGLFW = { } #if OFFSCREEN_FRAMEBUFFER // TODO: Make GLFW explicitly aware of whether it is being proxied or not, and set these to true only when proxying is being performed. - contextAttributes.renderViaOffscreenBackBuffer = true; - contextAttributes.preserveDrawingBuffer = true; + GL.enableOffscreenFramebufferAttributes(contextAttributes); #endif Module.ctx = Browser.createContext(Module['canvas'], true, true, contextAttributes); } diff --git a/src/library_glut.js b/src/library_glut.js index 260665cc433e5..bc143ddaec427 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -566,8 +566,7 @@ var LibraryGLUT = { }; #if OFFSCREEN_FRAMEBUFFER // TODO: Make glutCreateWindow explicitly aware of whether it is being proxied or not, and set these to true only when proxying is being performed. - contextAttributes.renderViaOffscreenBackBuffer = true; - contextAttributes.preserveDrawingBuffer = true; + GL.enableOffscreenFramebufferAttributes(contextAttributes); #endif Module.ctx = Browser.createContext(Module['canvas'], true, true, contextAttributes); return Module.ctx ? 1 /* a new GLUT window ID for the created context */ : 0 /* failure */; diff --git a/src/library_sdl.js b/src/library_sdl.js index af909cb6c47dc..e5205dfbc26bd 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -396,8 +396,7 @@ var LibrarySDL = { #if OFFSCREEN_FRAMEBUFFER // TODO: Make SDL explicitly aware of whether it is being proxied or not, and set these to true only when proxying is being performed. - webGLContextAttributes.renderViaOffscreenBackBuffer = true; - webGLContextAttributes.preserveDrawingBuffer = true; + GL.enableOffscreenFramebufferAttributes(webGLContextAttributes); #endif var ctx = Browser.createContext(canvas, is_SDL_OPENGL, usePageCanvas, webGLContextAttributes);