Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 为iPad视网膜更新OpenGL ES触摸检测(光线跟踪)?_Ios_Objective C_Opengl Es_Raytracing_Glkit - Fatal编程技术网

Ios 为iPad视网膜更新OpenGL ES触摸检测(光线跟踪)?

Ios 为iPad视网膜更新OpenGL ES触摸检测(光线跟踪)?,ios,objective-c,opengl-es,raytracing,glkit,Ios,Objective C,Opengl Es,Raytracing,Glkit,我有下面用于光线跟踪的代码。该代码在非视网膜iPad上成功运行,但在视网膜iPad上不起作用。触摸被检测到,但转换点在其应位于的左侧和下方关闭。有人能建议我如何更新下面的内容以适应视网膜屏幕吗 - (void)handleTap: (UITapGestureRecognizer *)recognizer { CGPoint tapLoc = [recognizer locationInView:self.view]; bool testResult; GLint v

我有下面用于光线跟踪的代码。该代码在非视网膜iPad上成功运行,但在视网膜iPad上不起作用。触摸被检测到,但转换点在其应位于的左侧和下方关闭。有人能建议我如何更新下面的内容以适应视网膜屏幕吗

- (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) {

        ...

} 

只需在[UIScreen Main Screen]上将tapLoc的x和y相乘即可。缩放 和1024*[UIScreen mainScreen]。缩放或替换为视口[3]

我想是这样的:

- (void)handleTap: (UITapGestureRecognizer *)recognizer
{

    CGPoint tapLoc = [recognizer locationInView:self.view];
    tapLoc.x *= [UIScreen mainScreen].scale;
    tapLoc.y *= [UIScreen mainScreen].scale;

    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-viewport[3]+uiKitOffset)*-1, 0.0), modelViewMatrix, projectionMatrix, &viewport[0] , &testResult);

    GLKVector3 farPt = GLKMathUnproject(GLKVector3Make(tapLoc.x, (tapLoc.y-viewport[3]+uiKitOffset)*-1, 1.0), modelViewMatrix, projectionMatrix, &viewport[0] , &testResult);

    farPt = GLKVector3Subtract(farPt, nearPt);

    ....
} 

谢谢-希望iPad Air能继续使用。@Ohnomycoco当然,iPad 3/4、iPad Air和iPad mini retina的屏幕分辨率是一样的,即使在iPhone上,这段代码也能正常工作。因为我替换了视口[3]上的1024,它存储GL上下文的高度。检查GLV视口