@@ -447,22 +447,22 @@ -(CGSize)viewSizeInPixels
447
447
-(CGRect)viewportRect
448
448
{
449
449
// TODO It's _possible_ that a user will use a non-axis aligned projection. Weird, but possible.
450
- kmMat4 projection ;
451
- kmGLGetMatrix (KM_GL_PROJECTION, &projection );
452
-
453
- kmMat4 projectionInv ;
454
- kmMat4Inverse (&projectionInv , &projection );
450
+ kmMat4 transform ;
451
+ GLToClipTransform (&transform );
452
+
453
+ kmMat4 transformInv ;
454
+ kmMat4Inverse (&transformInv , &transform );
455
455
456
456
// Calculate z=0 using -> transform*[0, 0, 0, 1]/w
457
- kmScalar zClip = projection .mat [14 ]/projection .mat [15 ];
457
+ kmScalar zClip = transform .mat [14 ]/transform .mat [15 ];
458
458
459
459
// Bottom left and top right coordinates of viewport in clip coords.
460
460
kmVec3 clipBL = {-1.0 , -1.0 , zClip};
461
461
kmVec3 clipTR = { 1.0 , 1.0 , zClip};
462
462
463
463
kmVec3 glBL, glTR;
464
- kmVec3TransformCoord (&glBL, &clipBL, &projectionInv );
465
- kmVec3TransformCoord (&glTR, &clipTR, &projectionInv );
464
+ kmVec3TransformCoord (&glBL, &clipBL, &transformInv );
465
+ kmVec3TransformCoord (&glTR, &clipTR, &transformInv );
466
466
467
467
return CGRectMake (glBL.x , glBL.y , glTR.x - glBL.x , glTR.y - glBL.y );
468
468
}
0 commit comments