Skip to content

Commit

Permalink
fixed scale on newer phone models, using [UIScreen mainScreen].native…
Browse files Browse the repository at this point in the history
…Scale instead of .scale
  • Loading branch information
mayakraft committed Dec 22, 2017
1 parent 6d444c5 commit 6bb717a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Binary file removed .DS_Store
Binary file not shown.
10 changes: 7 additions & 3 deletions Panorama/PanoramaView.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ @interface PanoramaView (){
UIPanGestureRecognizer *panGesture;
GLKMatrix4 _projectionMatrix, _attitudeMatrix, _offsetMatrix;
float _aspectRatio;
float _retinaScale;
GLfloat circlePoints[64*3]; // meridian lines
}
@end
Expand Down Expand Up @@ -144,6 +145,10 @@ -(void)initOpenGL:(EAGLContext*)context{
[(CAEAGLLayer*)self.layer setOpaque:NO];
_aspectRatio = self.frame.size.width/self.frame.size.height;
_fieldOfView = 45 + 45 * atanf(_aspectRatio); // hell ya
_retinaScale = [UIScreen mainScreen].scale;
if ([[UIScreen mainScreen] respondsToSelector:@selector(nativeScale)]){
_retinaScale = [UIScreen mainScreen].nativeScale;
}
[self rebuildProjectionMatrix];
_attitudeMatrix = GLKMatrix4Identity;
_offsetMatrix = GLKMatrix4Identity;
Expand Down Expand Up @@ -175,15 +180,14 @@ -(void)draw{
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
if(_VRMode) {
float scale = [UIScreen mainScreen].scale;
// one eye
glMatrixMode(GL_PROJECTION);
glViewport(0, 0, self.frame.size.width * scale, self.frame.size.height * scale * 0.5);
glViewport(0, 0, self.frame.size.width * _retinaScale, self.frame.size.height * _retinaScale * 0.5);
glMatrixMode(GL_MODELVIEW);
[self renderScene];
// other eye
glMatrixMode(GL_PROJECTION);
glViewport(0, self.frame.size.height * scale * 0.5, self.frame.size.width * scale, self.frame.size.height * scale* 0.5);
glViewport(0, self.frame.size.height * _retinaScale * 0.5, self.frame.size.width * _retinaScale, self.frame.size.height * _retinaScale * 0.5);
glMatrixMode(GL_MODELVIEW);
[self renderScene];
}else{
Expand Down

0 comments on commit 6bb717a

Please sign in to comment.