How to rotate OpenGL to suit iPhone landscape mode?

I am porting an existing cross-platform program that I have done in C ++ and from OpenGL / ES to iPhone. Please keep in mind, I don't know anything about Objective-C ...

I just briefly edited the Objective-C files of one of the lessons in order to properly initialize OpenGL for the iPhone, and just call my multi-platform C ++ code for everything else.

My program will only work in landscape mode, so I installed it as the only supported interface orientation (in the info.plist file).

What I want to know is how I should say that OpenGL rotates in accordance with landscape mode. I have currently added glRotate, which does this before the drauver, but this is a dirty trick.

Another thing: I try to convert strokes to mouse coordinates equivalent to another quick method, and I get a point located at a distance of 80 pixels on the X axis and 80 pixels on the Y axis. I added another dirty fix (with GlTranslatef) to this mess and I will get the correct coordinates, except that ... the color selection is wrong.

To be clear, the color selection does not detect anything on the first 160 pixels on the left (which is 2 * 80 and 480 - 320, therefore, yes, there is a 99% chance that this is caused by my dirty code ...)

What is the right way to handle this?

+3
source share
2 answers

, OpenGL . , . shouldAutoRotateToInterfaceOrientation: :

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation {
    return orientation == UIInterfaceOrientationLandscapeLeft; // Or ...Right
}

, , (, ) , Interface Builder , .

+1

iPhone 3G . mustAutoRotateToInterfaceOrientation OpenGL , OpenGL. , .

0

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


All Articles