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

Method projectGL

core/2d/Camera.cpp:302–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

300}
301
302Vec2 Camera::projectGL(const Vec3& src) const
303{
304 Vec2 screenPos;
305
306 auto viewport = _director->getWinSize();
307 Vec4 clipPos;
308 getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos);
309
310 if (clipPos.w == 0.0f)
311 AXLOGW("WARNING: Camera's clip position w is 0.0! a black screen should be expected.");
312
313 float ndcX = clipPos.x / clipPos.w;
314 float ndcY = clipPos.y / clipPos.w;
315
316 screenPos.x = (ndcX + 1.0f) * 0.5f * viewport.width;
317 screenPos.y = (ndcY + 1.0f) * 0.5f * viewport.height;
318 return screenPos;
319}
320
321Vec3 Camera::unproject(const Vec3& src) const
322{

Callers 3

checkVisibilityMethod · 0.80
cullRectangleFunction · 0.80
_checkVisibilityMethod · 0.80

Calls 2

transformVectorMethod · 0.80
Vec4Function · 0.50

Tested by

no test coverage detected