1 decade ago by marcinignac
Hi,
I recently made my WebGL engine work with Ejecta, well almost. I run into problems caused by internal handling of backingStoreRatio. I.e. When we have retina screen Ejecta doubles all the calls to gl.viewport or drawingBufferWidth. While this is convenient for people who don't know what's happening and use canvas.width and canvas.height for their code I run into problems with FBO where my viewport is too big. E.g.
This is super confusing because now my code that is offscreen has to know about window stuff and i have to call
I would rather do
I recently made my WebGL engine work with Ejecta, well almost. I run into problems caused by internal handling of backingStoreRatio. I.e. When we have retina screen Ejecta doubles all the calls to gl.viewport or drawingBufferWidth. While this is convenient for people who don't know what's happening and use canvas.width and canvas.height for their code I run into problems with FBO where my viewport is too big. E.g.
//create FrameBuffer object with 1 backing texture as color target var fbo = new FBO(512, 512); function draw() { fbo.bind(); gl.viewport(0, 0, 512, 512); //my viewport is 1024x1024!!! drawScene(); fbo.unbind(); //back to fullscreen viewport gl.viewport(0, 0, canvas.width, canvas.height); }
This is super confusing because now my code that is offscreen has to know about window stuff and i have to call
gl.viewport(0, 0, fbo.width/2, fbo.height/2);
I would rather do
gl.viewport( 0, 0, canvas.width * window.devicePixelRatio, canvas.height * window.devicePixelRatio );