Skip to content

Instantly share code, notes, and snippets.

View AyadiMehdi's full-sized avatar

Mehdi Ayadi AyadiMehdi

  • Université Lyon 2
  • Lyon - France
View GitHub Profile
@AyadiMehdi
AyadiMehdi / GLKMathUtils
Created March 8, 2017 12:02 — forked from sakrist/GLKMathUtils
GLKMathProject and GLKMathUnproject
GLKVector3 GLKMathProject(GLKVector3 object, GLKMatrix4 model, GLKMatrix4 projection, int *viewport) {
assert(viewport);
GLKVector4 v4 = GLKVector4MakeWithVector3(object, 1.0);
GLKVector4 v = GLKMatrix4MultiplyVector4(model, v4);
v = GLKMatrix4MultiplyVector4(projection, v);
v.v[3] = 1.0/v.v[3];
v.v[0] *= v.v[3];
v.v[1] *= v.v[3];