Note that there are some explanatory texts on larger screens.

plurals
  1. POTransformations seem to work improperly
    primarykey
    data
    text
    <p>Ok, so I have a weird problem with OpenGL in landscape mode on iOS. From what I've read on the internet I have to rotate the scene myself, so I did that like this:</p> <pre><code>void GameViewController::onSurfaceChanged(int width, int height) { float aspect = (float)width / (float)height; float fovy = 90.0f; glMatrixMode(GL_PROJECTION); float xmin, xmax, ymin, ymax; ymax = 0.01f * Math::tan(fovy * 3.1415f / 360.0); ymin = -ymax; xmin = ymin * aspect; xmax = ymax * aspect; glViewport(0, 0, width, height); glLoadIdentity(); glRotatef(-90.0f, 0.0f, 0.0f, 1.0f); glFrustumf(xmin, xmax, ymin, ymax, 0.01f, 320.0f); } </code></pre> <p>My center of my camera isn't the center of the screen now though. So I reset all matrices (projection, modelview) so they are all identity, and then I drew a unit circle on the screen. Now I see what's going wrong, not all coordinates from -1 to 1 are actually on my screen! Here is a screenshot to show what I mean: <img src="https://i.stack.imgur.com/pu7n6.png" alt="circle that should be in the center of the screen"></p> <p>Now my question: what could possibly cause this?</p> <p>EDIT: after some more investigation i found that in this obj-c method:</p> <pre><code>-(void)setupView:(GLView*)view { CGRect rect = view.bounds; glViewport(0, 0, rect.size.width, rect.size.height); gameView-&gt;onSurfaceCreated(); gameView-&gt;onSurfaceChanged(rect.size.width, rect.size.height); view.multipleTouchEnabled = YES; } </code></pre> <p>the view's size suddenly turned out to be 1216*1568. The problem is probably there. Manually passing 768 * 1024 to onSurfaceChanged gives me even weirder results.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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