iphone横向模式问题再次出现

iphone横向模式问题再次出现,iphone,objective-c,opengl-es,Iphone,Objective C,Opengl Es,我已经测试了所有的东西,但是我不能让它工作 以下是我设置程序的方式: CGRect contentRect = CGRectMake(0, 0, 480, 320); CGRect screenBounds = [[UIScreen mainScreen] bounds]; _window = [[UIWindow alloc] initWithFrame: contentRect]; _view = [[GLView alloc] initWithFrame: screenBounds]; C

我已经测试了所有的东西,但是我不能让它工作

以下是我设置程序的方式:

CGRect contentRect = CGRectMake(0, 0, 480, 320);
CGRect screenBounds = [[UIScreen mainScreen] bounds];
_window = [[UIWindow alloc] initWithFrame: contentRect];
_view = [[GLView alloc] initWithFrame: screenBounds];
CGAffineTransform transform = CGAffineTransformMakeRotation(3.14159/2);
_view.transform = transform;


_window.frame = contentRect;
_window.bounds = contentRect;
_window.window.bounds = contentRect;
_window.frame = contentRect;

_view.window.bounds = contentRect;
_view.bounds = contentRect;
_view.bounds = contentRect;
_view.frame = contentRect;

[_window addSubview: _view];
[_window makeKeyAndVisible];
我的opengl设置如下:

glViewport(0, 0, 480, 320);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glOrthof( 0, 480, 0, 320, -1, 1 );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
你可以看到右边三分之一是黑色的?我错过了什么?

你应该在模型/视图矩阵中设置旋转,而不是在视图中设置旋转。

应用程序是在纵向模式下启动的,然后旋转到横向模式吗?是的,我不知道如何从一开始就选择横向模式。我在.plist文件中设置了横向模式,但这只会旋转手机,而不会旋转手机的内容。当我使用glViewport(320,480)设置查看端口时,M_PI_2可以方便地替代3.14159/2,并且我只设置了_view.bounds=(480,320),一切看起来都正常。但是我不能在不扭曲图像的情况下做glGetPixels,因为我猜glGetPixels是从视口中获取其大小的,对吗?因为如果视口是320*480,那么我必须在glGetPixels中设置此值以获取所有内容,然后图像是320*480,而不是我喜欢的480*320。嗯,我看不出问题。旋转生成的图像。旋转是正确的,高度是480而不是320,反之亦然。因此,如果在y方向缩小,在x方向放大,这将是正确的图像,但如何做到这一点呢?