0
我有我正在使用的光线跟踪下面的代码。该代码可以在非视网膜iPad上成功运行,但不能在视网膜iPad上运行。触摸被检测到,但是转换后的点向左和向下偏离应该位置。任何人都可以建议我如何更新下面以适应视网膜屏幕?更新iPad Retina的OpenGL ES Touch Detection(光线追踪)?
- (void)handleTap: (UITapGestureRecognizer *)recognizer
{
CGPoint tapLoc = [recognizer locationInView:self.view];
bool testResult;
GLint viewport[4];
glGetIntegerv(GL_VIEWPORT, viewport);
float uiKitOffset = 113; //Need to factor in the height of the nav bar + the height of the tab bar at the bottom in the storyboard.
GLKVector3 nearPt = GLKMathUnproject(GLKVector3Make(tapLoc.x, (tapLoc.y-1024+uiKitOffset)*-1, 0.0), modelViewMatrix, projectionMatrix, &viewport[0] , &testResult);
GLKVector3 farPt = GLKMathUnproject(GLKVector3Make(tapLoc.x, (tapLoc.y-1024+uiKitOffset)*-1, 1.0), modelViewMatrix, projectionMatrix, &viewport[0] , &testResult);
farPt = GLKVector3Subtract(farPt, nearPt);
for (Object * Object in self.objectArray) {
...
}
谢谢 - 希望iPad Air能够举办。 – GuybrushThreepwood
@Ohnomycoco当然,iPad 3/4和iPad Air以及iPad mini视网膜具有相同的屏幕分辨率,即使在iPhone上也没有任何问题,此代码也可以正常工作。因为我用视口[3]取代了你的1024,它存储了GL上下文的高度。检查glViewport http://www.opengl.org/sdk/docs/man/xhtml/glViewport.xml – SAKrisT