@@ -175,31 +175,34 @@ nativeBindings.nativeGl.onconstruct = (gl, canvas) => {
175175 gl . setWindowHandle ( windowHandle ) ;
176176 gl . setDefaultVao ( vao ) ;
177177
178- const nativeWindowSize = nativeWindow . getFramebufferSize ( windowHandle ) ;
178+ /* const nativeWindowSize = nativeWindow.getFramebufferSize(windowHandle);
179179 const nativeWindowHeight = nativeWindowSize.height;
180180 const nativeWindowWidth = nativeWindowSize.width;
181181
182- // Calculate devicePixelRatio.
183- window . devicePixelRatio = nativeWindowWidth / canvasWidth ;
184-
185182 // Tell DOM how large the window is.
186- window . innerHeight = nativeWindowHeight / window . devicePixelRatio ;
187- window . innerWidth = nativeWindowWidth / window . devicePixelRatio ;
183+ window.innerHeight = nativeWindowSize.height ;
184+ window.innerWidth = nativeWindowSize.width; */
188185
189186 const title = `Exokit ${ version } ` ;
190187 nativeWindow . setWindowTitle ( windowHandle , title ) ;
191188
189+ const [ fbo , tex , depthTex , msFbo , msTex , msDepthTex ] = nativeWindow . createRenderTarget ( gl , canvasWidth , canvasHeight , sharedColorTexture , sharedDepthStencilTexture , sharedMsColorTexture , sharedMsDepthStencilTexture ) ;
190+ gl . setDefaultFramebuffer ( msFbo ) ;
191+ gl . framebuffer = {
192+ msFbo,
193+ msTex,
194+ msDepthTex,
195+ fbo,
196+ tex,
197+ depthTex,
198+ } ;
199+ gl . resize = ( width , height ) => {
200+ nativeWindow . setCurrentWindowContext ( windowHandle ) ;
201+ nativeWindow . resizeRenderTarget ( gl , width , height , fbo , tex , depthTex , msFbo , msTex , msDepthTex ) ;
202+ } ;
203+
192204 const { hidden} = document ;
193205 if ( hidden ) {
194- const [ fbo , tex , depthTex , msFbo , msTex , msDepthTex ] = nativeWindow . createRenderTarget ( gl , canvasWidth , canvasHeight , sharedColorTexture , sharedDepthStencilTexture , sharedMsColorTexture , sharedMsDepthStencilTexture ) ;
195-
196- gl . setDefaultFramebuffer ( msFbo ) ;
197-
198- gl . resize = ( width , height ) => {
199- nativeWindow . setCurrentWindowContext ( windowHandle ) ;
200- nativeWindow . resizeRenderTarget ( gl , width , height , fbo , tex , depthTex , msFbo , msTex , msDepthTex ) ;
201- } ;
202-
203206 // TODO: handle multiple child canvases
204207 document . framebuffer = {
205208 canvas,
@@ -210,11 +213,6 @@ nativeBindings.nativeGl.onconstruct = (gl, canvas) => {
210213 tex,
211214 depthTex,
212215 } ;
213- } else {
214- gl . resize = ( width , height ) => {
215- nativeWindow . setCurrentWindowContext ( windowHandle ) ;
216- nativeWindow . resizeRenderTarget ( gl , width , height , sharedFramebuffer , sharedColorTexture , sharedDepthStencilTexture , sharedMsFramebuffer , sharedMsColorTexture , sharedMsDepthStencilTexture ) ;
217- } ;
218216 }
219217
220218 const ondomchange = ( ) => {
@@ -477,6 +475,7 @@ class XRState {
477475 }
478476 return result ;
479477 } ) ( ) ;
478+ this . devicePixelRatio = _makeTypedArray ( Uint32Array , 1 ) ;
480479 }
481480}
482481const xrState = GlobalContext . xrState = new XRState ( ) ;
@@ -1170,13 +1169,13 @@ nativeBindings.nativeWindow.setEventHandler((type, data) => {
11701169 break ;
11711170 }
11721171 case 'framebufferResize' : {
1173- const { width, height} = data ;
1172+ /* const {width, height} = data;
11741173 innerWidth = width;
11751174 innerHeight = height;
11761175
11771176 window.innerWidth = innerWidth / window.devicePixelRatio;
11781177 window.innerHeight = innerHeight / window.devicePixelRatio;
1179- window . dispatchEvent ( new window . Event ( 'resize' ) ) ;
1178+ window.dispatchEvent(new window.Event('resize')); */
11801179 break ;
11811180 }
11821181 case 'keydown' : {
@@ -1385,7 +1384,8 @@ const _startRenderLoop = () => {
13851384
13861385 const width = vrPresentState . glContext . canvas . width * ( args . blit ? 0.5 : 1 ) ;
13871386 const height = vrPresentState . glContext . canvas . height ;
1388- nativeWindow . blitFrameBuffer ( context , vrPresentState . msFbo , 0 , width , height , width , height , true , false , false ) ;
1387+ const { width : dWidth , height : dHeight } = nativeWindow . getFramebufferSize ( windowHandle ) ;
1388+ nativeWindow . blitFrameBuffer ( context , vrPresentState . msFbo , 0 , width , height , dWidth , dHeight , true , false , false ) ;
13891389 } else if ( vrPresentState . glContext === context && vrPresentState . system && vrPresentState . hasPose ) {
13901390 if ( vrPresentState . layers . length > 0 ) {
13911391 const { openVRDisplay} = window [ symbols . mrDisplaysSymbol ] ;
@@ -1400,7 +1400,8 @@ const _startRenderLoop = () => {
14001400
14011401 const width = vrPresentState . glContext . canvas . width * ( args . blit ? 0.5 : 1 ) ;
14021402 const height = vrPresentState . glContext . canvas . height ;
1403- nativeWindow . blitFrameBuffer ( context , vrPresentState . msFbo , 0 , width , height , width , height , true , false , false ) ;
1403+ const { width : dWidth , height : dHeight } = nativeWindow . getFramebufferSize ( windowHandle ) ;
1404+ nativeWindow . blitFrameBuffer ( context , vrPresentState . fbo , 0 , width , height , dWidth , dHeight , true , false , false ) ;
14041405 } else if ( oculusMobileVrPresentState . glContext === context && oculusMobileVrPresentState . hasPose ) {
14051406 if ( oculusMobileVrPresentState . layers . length > 0 ) {
14061407 const { oculusMobileVrDisplay} = window [ symbols . mrDisplaysSymbol ] ;
@@ -1423,10 +1424,19 @@ const _startRenderLoop = () => {
14231424
14241425 mlPresentState . mlContext . SubmitFrame ( mlPresentState . mlTex , mlPresentState . mlGlContext . canvas . width , mlPresentState . mlGlContext . canvas . height ) ;
14251426 mlPresentState . mlHasPose = false ;
1426- } else if ( fakePresentState . layers . length > 0 ) {
1427- const { fakeVrDisplay} = window [ symbols . mrDisplaysSymbol ] ;
1428- _decorateModelViewProjections ( fakePresentState . layers , fakeVrDisplay , 1 ) ;
1429- nativeWindow . composeLayers ( context , 0 , fakePresentState . layers ) ;
1427+ } else {
1428+ if ( fakePresentState . layers . length > 0 ) {
1429+ const { fakeVrDisplay} = window [ symbols . mrDisplaysSymbol ] ;
1430+ _decorateModelViewProjections ( fakePresentState . layers , fakeVrDisplay , 1 ) ;
1431+ nativeWindow . composeLayers ( context , context . framebuffer . fbo , fakePresentState . layers ) ;
1432+ } else {
1433+ nativeWindow . blitFrameBuffer ( context , context . framebuffer . msFbo , context . framebuffer . fbo , context . canvas . width , context . canvas . height , context . canvas . width , context . canvas . height , true , false , false ) ;
1434+ }
1435+
1436+ const width = context . canvas . width * ( args . blit ? 0.5 : 1 ) ;
1437+ const height = context . canvas . height ;
1438+ const { width : dWidth , height : dHeight } = nativeWindow . getFramebufferSize ( windowHandle ) ;
1439+ nativeWindow . blitFrameBuffer ( context , context . framebuffer . fbo , 0 , width , height , dWidth , dHeight , true , false , false ) ;
14301440 }
14311441 }
14321442
@@ -2106,8 +2116,8 @@ const _startRenderLoop = () => {
21062116let currentRenderLoop = _startRenderLoop ( ) ;
21072117
21082118const _bindWindow = ( window , newWindowCb ) => {
2109- window . innerWidth = innerWidth ;
2110- window . innerHeight = innerHeight ;
2119+ // window.innerWidth = innerWidth;
2120+ // window.innerHeight = innerHeight;
21112121
21122122 window . on ( 'navigate' , newWindowCb ) ;
21132123 window . document . on ( 'paste' , e => {
0 commit comments