Browse Source

Updated examples/webgl_multiple_views.html with retina support

Thomas Skardal 11 years ago
parent
commit
3e357d905d
1 changed files with 7 additions and 4 deletions
  1. 7 4
      examples/webgl_multiple_views.html

+ 7 - 4
examples/webgl_multiple_views.html

@@ -53,6 +53,8 @@
 
 			var windowWidth, windowHeight;
 
+                        var dpr = window.devicePixelRatio || 1;
+
 			var views = [
 				{ 
 					left: 0,
@@ -283,10 +285,11 @@
 
 					view.updateCamera( camera, scene, mouseX, mouseY );
 
-					var left   = Math.floor( windowWidth  * view.left );
-					var bottom = Math.floor( windowHeight * view.bottom );
-					var width  = Math.floor( windowWidth  * view.width );
-					var height = Math.floor( windowHeight * view.height );
+                                        // multiply by the device pixel ratio in order to properly support high DPI displays
+					var left   = Math.floor( windowWidth  * view.left ) * dpr;
+					var bottom = Math.floor( windowHeight * view.bottom ) * dpr;
+					var width  = Math.floor( windowWidth  * view.width ) * dpr;
+					var height = Math.floor( windowHeight * view.height ) * dpr;
 					renderer.setViewport( left, bottom, width, height );
 					renderer.setScissor( left, bottom, width, height );
 					renderer.enableScissorTest ( true );