OpenGL ES view: how to orient it to the landscape?

We are looking for clues regarding the orientation of the OpenGL ES application in the landscape, most of the information I found relates to 2008, most of which relate to earlier versions of the SDK. Apparently, back in those days, in the case of GL, it was recommended not to rotate the view, but instead use rotation as a GL transformation. Is this still the case with the current SDKs? It would be easier to just rotate the window: all touch events will be synchronized with rotation.

In other words: how to customize the OpenGL view in landscape mode?

+3
source share
3 answers

( , . , .)

CAEAGLLayer Apple ( ), GL: " , CAEAGLLayer, ". , , .

, . , .

glPushMatrix();
  glRotatef(90, 0.0, 0.0, 1.0);
  glTranslatef(0.0f, -320.0f, 0.0f );

  // *** ALL RENDERING GOES HERE ***

glPopMatrix();

iPad, -320 -768.

UIT:

int touchx = touch.y;
int touchy = viewWidth - touch.x;
+7

, . OpenGL ES, :

" iOS 4.2 Core Animation . , 32 ."

:

[eaglLayer setAffineTransform:CGAffineTransformMakeRotation( -90 * M_PI  / 180)];

CAEAGLLayer : " , CAEAGLLayer, ". , . - 2008-05-19.

FYI, Q & A, .

+5

You need to adjust the camera matrix with the vector up along the X axis, and not along the Y axis, which you usually do. Rotating the world 90 degrees works, but makes it difficult to work with everything else.

Use somthing like:

up.x = 1; // instead of up.y
up.y = 0;
up.z = 0;
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
GLU.gluLookAt(gl, position.x, position.y, position.z, lookAt.x, lookAt.y, lookAt.z, up.x, up.y, up.z);
+1
source

Source: https://habr.com/ru/post/1726187/


All Articles