TLW
TLW

Reputation: 1439

Sharing buffers in webgl

I'd like to be able to share the depth and stencil buffer(s) between the on-screen buffer and an off-screen buffer. (Or, to phrase it a different way, I want to be able to render to a texture using the on-screen depth and stencil buffer.)

I tried to bind a shared depth / stencil renderbuffer to the default framebuffer, only for it to error out with "cannot modify framebuffer 0". Ok, so I cannot modify the onscreen framebuffer.

I then tried to bind the default framebuffer's stencil / depth buffer(s) to the secondary render buffer, but, again, it errored out with "cannot query framebuffer 0".

My current workaround is to create two off-screen framebuffers, and at the end splat the main off-screen buffer to screen via a texture and a fullscreen quad. Not exactly pretty.

Unfortunately, webgl is based on OpenGL ES, and this question suggests that there is no way to do this for OpenGL ES. As such, I suspect, although I hope that I am wrong, that there is no "better" way.

Upvotes: 2

Views: 745

Answers (1)

LJᛃ
LJᛃ

Reputation: 8153

Not possible.

WebGL 1.0 specification § 5.14.6:

If framebuffer is null, the default framebuffer provided by the context is bound and attempts to modify or query state on target FRAMEBUFFER will generate an INVALID_OPERATION error.

Upvotes: 3

Related Questions