MCPcopy Create free account
hub / github.com/axmolengine/axmol / convertToGL

Method convertToGL

core/base/Director.cpp:715–733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

713}
714
715Vec2 Director::convertToGL(const Vec2& uiPoint)
716{
717 Mat4 transform;
718 GLToClipTransform(&transform);
719
720 Mat4 transformInv = transform.getInversed();
721
722 // Calculate z=0 using -> transform*[0, 0, 0, 1]/w
723 float zClip = transform.m[14] / transform.m[15];
724
725 Vec2 glSize = _renderView->getDesignResolutionSize();
726 Vec4 clipCoord(2.0f * uiPoint.x / glSize.width - 1.0f, 1.0f - 2.0f * uiPoint.y / glSize.height, zClip, 1);
727
728 Vec4 glCoord;
729 // transformInv.transformPoint(clipCoord, &glCoord);
730 transformInv.transformVector(clipCoord, &glCoord);
731 float factor = 1.0f / glCoord.w;
732 return Vec2(glCoord.x * factor, glCoord.y * factor);
733}
734
735Vec2 Director::convertToUI(const Vec2& glPoint)
736{

Callers 12

getLocationMethod · 0.80
getPreviousLocationMethod · 0.80
getStartLocationMethod · 0.80
getLocationMethod · 0.80
getPreviousLocationMethod · 0.80
getStartLocationMethod · 0.80
onTouchesBeganMethod · 0.80
onTouchesMovedMethod · 0.80
onTouchesBeganMethod · 0.80
onTouchesMovedMethod · 0.80
handleTouchEventMethod · 0.80
handleTouchesEventMethod · 0.80

Calls 4

GLToClipTransformFunction · 0.85
transformVectorMethod · 0.80
Vec2Class · 0.70
getInversedMethod · 0.45

Tested by 4

onTouchesBeganMethod · 0.64
onTouchesMovedMethod · 0.64
onTouchesBeganMethod · 0.64
onTouchesMovedMethod · 0.64