Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I'm assuming what you want to achieve is a "square" projection, e.g. when you draw a circle you want it to look like a circle rather than an ellipse.</p> <p>The only thing you should play with is your projection (camera) aspect ratio. In normal cases, monitors keep pixels square and all you have to do is set your camera aspect ratio equal to your viewport's aspect ratio:</p> <pre><code>viewport_aspect_ratio = viewport_res_x / viewport_res_y; camera_aspect_ratio = viewport_aspect_ratio; </code></pre> <p>In the stretched case you describe (4:3 image stretched on a 16:10 screen for example), pixels are not square anymore and you have to take that into account in your camera aspect ratio:</p> <pre><code>stretch_factor_x = screen_size_x / viewport_res_x; stretch_factor_y = screen_size_y / viewport_res_y; pixel_aspect_ratio = stretch_factor_x / stretch_factor_y; viewport_aspect_ratio = viewport_res_x / viewport_res_y; camera_aspect_ratio = viewport_aspect_ratio * pixel_aspect_ratio; </code></pre> <p>Where <code>screen_size_x</code> and <code>screen_size_y</code> are multiples of the real size of the monitor (e.g. 16:10).</p> <p>However, you should simply assume square pixels (unless you have a specific reason no to), as the monitor may report incorrect physical size informations to the system, or no informations at all. Also monitors don't always stretch, mine for example keeps 1:1 pixels aspect ratio and adds black borders for lower resolutions.</p> <p><strong>Edit</strong></p> <p>If you want to adjust your viewport to some aspect ratio and fit it on an arbitrary resolution then you could do like that :</p> <pre><code>viewport_aspect_ratio = 16.0 / 10.0; // The aspect ratio you want your viewport to have screen_aspect_ratio = screen_res_x / screen_res_y; if (viewport_aspect_ratio &gt; screen_aspect_ratio) { // Viewport is wider than screen, fit on X viewport_res_x = screen_res_x; viewport_res_y = viewport_res_x / viewport_aspect_ratio; } else { // Screen is wider than viewport, fit on Y viewport_res_y = screen_res_y; viewport_res_x = viewport_res_y * viewport_aspect_ratio; } camera_aspect_ratio = viewport_res_x / viewport_res_y; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload