我知道屏幕的左上角(假設手機左側橫向)是(0,0)。但是,如果我想讓我的(0,0)點成爲左下角而不是左上角,那我該怎麼做?手動旋轉橫向模式左側的座標系
我想在指定位置使用OpenGL繪製對象,我當前正在屏幕上觸摸,但y值正在屏幕的錯誤一側繪製。下面是一個問題的例子,如果它有幫助。請注意,白點是我觸摸屏幕的地方,紫色是我使用OpenGL繪製的粒子系統。
設置我支持的接口是這樣的:
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
在我drawFrame
方法:
glViewport(0, 0, 480, 320);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof(0.0f, 480, 0.0f, 320, -100.0f, 100.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//render the particles being drawn, etc
在我touchesBegan
方法:
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (pe.active != YES)
{
pe.active = YES;
NSLog(@"x: %f y: %f", location.x, location.y);
pe.sourcePosition = Vector2fMake(location.x, location.y);
}
然後我試圖手動通過在我的viewWillAppear
方法這樣做90度旋轉座標系:
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation((M_PI * (-90)/180.0));
self.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
指定CGAffineTransformMakeRotation
呼叫與如上所示-90度應改變的座標系統,但它沒有。
任何幫助,非常感謝。
我沒有看到任何OpenGL。繪圖時更改座標系。 – 2013-04-23 23:30:30
我編輯了我的問題並添加了圖片以更好地解釋我的問題,謝謝。 – coderz 2013-04-24 01:33:34