Skip to content

Commit

Permalink
Add support for high resolution displays. slowe#71
Browse files Browse the repository at this point in the history
  • Loading branch information
René Schulze committed May 9, 2020
1 parent 4080240 commit 1965853
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
12 changes: 10 additions & 2 deletions virtualsky.js
Original file line number Diff line number Diff line change
Expand Up @@ -1167,19 +1167,26 @@ VirtualSky.prototype.getPhrase = function(key,key2){
else return this.htmlDecode(this.lang[key2]);
}else return this.htmlDecode(this.lang[key]) || this.htmlDecode(this.langs.en[key]) || "";
};
VirtualSky.prototype.getDevicePixelRatio = function(){
return window.devicePixelRatio;
};
VirtualSky.prototype.resize = function(w,h){
if(!this.canvas) return;
if(!w || !h){
if(this.fullscreen){
this.canvas.css({'width':0,'height':0});
w = window.innerWidth;
h = window.innerHeight;
this.canvas.width = w;
this.canvas.height = h;
this.canvas.css({'width':w+'px','height':h+'px'});
}else{
// We have to zap the width of the canvas to let it take the width of the container
this.canvas.css({'width':0,'height':0});
w = this.container.outerWidth();
h = this.container.outerHeight();
this.canvas.width = w;
this.canvas.height = h;
this.canvas.css({'width':w+'px','height':h+'px'});
}
}else{
Expand All @@ -1196,8 +1203,9 @@ VirtualSky.prototype.resize = function(w,h){
};
VirtualSky.prototype.setWH = function(w,h){
if(!w || !h) return;
this.c.width = w;
this.c.height = h;
this.c.width = w*this.getDevicePixelRatio();
this.c.height = h*this.getDevicePixelRatio();
this.c.getContext('2d').scale(this.getDevicePixelRatio(),this.getDevicePixelRatio());
this.wide = w;
this.tall = h;
this.changeFOV();
Expand Down
17 changes: 2 additions & 15 deletions virtualsky.min.js

Large diffs are not rendered by default.

0 comments on commit 1965853

Please sign in to comment.