Jump to content

How to control engine/canvas screen resolution?


ian
 Share

Recommended Posts

hi

yes you can :)

resize your canvas and create engine again and back to current size

you just lose your quality 

you can optimize that with detect retina display or (x2 ox3 or x4 or ultra ) and divide size to current

 

   canvas.style.width = "800px";
   canvas.style.height =   "600px"; 

    renderer = new BABYLON.Engine( canvas, true);

    canvas.style.width = '100%';
    canvas.style.height = '100%';
     

Link to comment
Share on other sites

  • 1 month later...

 canvas.style.width =  oldwidth /  window.devicePixelRatio;
   canvas.style.height =   oldheight / window.devicePixelRatio; 

    renderer = new BABYLON.Engine( canvas, true);

    canvas.style.width = '100%';
    canvas.style.height = '100%';

it can be help more

Link to comment
Share on other sites

As I believe @NasimiAsl might be directing you to consider:

    canvas.style.width = '80%';  //(80%), (75%) etc. as read below:
    canvas.style.height = '60%'; //as above, (60%) is simply an "arbitrary" variation on canvas size

- as I would certainly be specific in setting these percentages depending on my scene(s) and target device(s) - and I mention it in these terms as I rarely see developers rely on percentages as opposed to using strictly 100% in coordination with pixel size and aspect ratios.

So if you want to do some testing to avoid worrying about specific pixel resolution for multiple devices since many manufacturer's devices such as Apple Ipads often have dramatically different resolutions between releases on similar devices and OS only months apart by release date - and if you're not relying wholly on WebGL and instead relying on HTML for canvas size, you'll find that your canvas' will often be drawn very poorly when setting specific pixel resolutions as opposed to using varying canvas percentages. Just another point of view to consider, but one which often helps me build better optimized canvas' for browsers on differring hardware and OS with dramatically varying displays. Especially when it comes to smartphones.

DB

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...