oframe / ogl

Minimal WebGL Library
https://oframe.github.io/ogl/examples
3.77k stars 213 forks source link

Add ability to resize RenderTarget #91

Closed kirill-konshin closed 3 years ago

kirill-konshin commented 3 years ago

Currently looks like the values of width and height, provided to RenderTarget, are permanently bound to textures etc., which requires to re-create the RenderTarget if original gl.canvas.width has changed.

It would be great if there'd be some API to resize the RenderTarget.

gordonnl commented 3 years ago

So this is just the way that frame buffers work (or any typed array) - you can't change their length at will like with a javascript array. So the current approach OGL takes is to mimic the WebGL API in that users must re-create a RenderTarget upon resize.

A good example of this can be found in the Post extra class: https://github.com/oframe/ogl/blob/master/src/extras/Post.js#L79-L80

kirill-konshin commented 3 years ago

Makes sense, thank you for the answer. That's pretty much exactly how I solved it, by creating new targets in resize method.