Skip to content

Commit

Permalink
Add GL.enableOffscreenFramebufferAttributes() function to initialize …
Browse files Browse the repository at this point in the history
…context attributes for Offscreen Framebuffer use
  • Loading branch information
juj committed Feb 13, 2018
1 parent 12b93b2 commit ef6d60a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/library_gl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions src/library_glfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/library_glut.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */;
Expand Down
3 changes: 1 addition & 2 deletions src/library_sdl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit ef6d60a

Please sign in to comment.