visgotti Posted September 26, 2019 Share Posted September 26, 2019 In the first scenario - If I create the renderer like this const screenWidth = window.innerWidth; const screenHeight = window.innerHeight; const canvas = document.getElementById('canvas'); const renderer = PIXI.autoDetectRenderer({ forceCanvas: true, width: screenWidth, height: screenHeight, antialias: false, roundPixels: true, resolution: 2, view: canvas, }); renderer.view.width = screenWidth; renderer.view.height = screenHeight; renderer.view.style.width = screenWidth + 'px'; renderer.view.style.height = screenHeight + 'px'; renderer.view.style.display = 'block'; renderer.view.style.position = 'absolute'; renderer.view.style.top = '0'; renderer.view.style.left = '0'; renderer.view.style.zIndex = '-1'; renderer.backgroundColor = 0x000000; then I do const playerSpine = new PIXI.spine.Spine(r.player.spineData); playerSpine.skeleton.setSkinByName('base'); playerSpine.x = window.innerWidth / 4; playerSpine.y = window.innerHeight / 4; The player is in the middle of the webpage like I'd expect. But with the same exact code - if I create the renderer with the option - forceCanvas: false, I no longer see the player in the middle of the screen. I can't seem to figure out how webgl is positioning it. It seems like the webgl and canvas act differently when setting the resolution. No errors or anything. Anyone have an idea as to why this is happening? edit: here's the most simple code snippet to reproduce the problems https://github.com/visgotti/pixi-res-problem/ ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted September 26, 2019 Share Posted September 26, 2019 Note: if you use "gh-pages" branch (sometimes people use it by default), your demo will be accessible at visgotti.github.io/pixi-res-problem/ renderer = ... { resolution: 2} ) renderer.resize(600,400); // that makes canvas.width = 600 * 2 // renderer.screen is a rectangle (0,0, 600, 400) // renderer.view is canvas of size (1200, 800) People always have problem with "resolution" definition. Even if I explain everything in a few paragraphs - you'll get it only after you make an app or two that uses it. You have to look for "screen", "view", and how "autoDensity" works. You actually dont need it if you set "view.style.width" manually but look it anyway As for why webgl is different - its updating inner fields when you call "resize" Quote Link to comment Share on other sites More sharing options...
visgotti Posted September 26, 2019 Author Share Posted September 26, 2019 9 hours ago, ivan.popelyshev said: Note: if you use "gh-pages" branch (sometimes people use it by default), your demo will be accessible at visgotti.github.io/pixi-res-problem/ renderer = ... { resolution: 2} ) renderer.resize(600,400); // that makes canvas.width = 600 * 2 // renderer.screen is a rectangle (0,0, 600, 400) // renderer.view is canvas of size (1200, 800) People always have problem with "resolution" definition. Even if I explain everything in a few paragraphs - you'll get it only after you make an app or two that uses it. You have to look for "screen", "view", and how "autoDensity" works. You actually dont need it if you set "view.style.width" manually but look it anyway As for why webgl is different - its updating inner fields when you call "resize" Awesome thanks again ivan ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.