Surreal Posted November 26, 2016 Share Posted November 26, 2016 I am trying to create a stage which fills the browser window; as well as a window.onresize handler which resizes the renderer (and underlying canvas) to the new window size. Unfortunately it seems like if I simply set the renderer size to being window.innerWidth, window.innerHeight, I get scroll bars showing. The only way I can get rid of the scroll bars is to resize to innerWidth, innerHeight - 4. This of course leaves a 4 pixel high gap at the bottom of the browser window. As you can see in my screenshot, the canvas goes right up to the edge for the left, top, and right sides, but the gap is visible on the bottom. If the height is any greater than window.innerHeight - 4 (-2 or -1 for example), I get scrollbars. I do have this css in my html: <style>* {padding: 0; margin: 0}</style> Any ideas what I'm doing wrong to get a full sized canvas? I did notice that 'run pixie run' does not exhibit this behaviour (it was able to fill up the entire window), and glancing through the code and its resize function I didn't see much difference.. Thanks in advance! Quote Link to comment Share on other sites More sharing options...
Surreal Posted November 26, 2016 Author Share Posted November 26, 2016 After looking back through Run pixie run I noticed that the body css had overflow: hidden applied. This appears to do the trick for me. Quote Link to comment Share on other sites More sharing options...
xerver Posted November 26, 2016 Share Posted November 26, 2016 http://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html #3: Using window.innerWidth and window.innerHeight to compute anything vimino 1 Quote Link to comment Share on other sites More sharing options...
Surreal Posted November 26, 2016 Author Share Posted November 26, 2016 26 minutes ago, xerver said: http://webglfundamentals.org/webgl/lessons/webgl-anti-patterns.html #3: Using window.innerWidth and window.innerHeight to compute anything Hmm thanks for the link. Fortunately it looks like for this case it should be ok, as they say "Yes, it can work for WebGL pages where you want to make the canvas fill the screen. The problem comes when you don't." For a game that I want to take up the whole screen I think that's fine then Thanks again though, always appreciate an opportunity to learn more about things! 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.