Jump to content

Issue trying to create stage that fills browser window


Surreal
 Share

Recommended Posts

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!

example.png

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...