Accumulated transformation

Hello. I’am developing control for visualising raster maps (google maps, mapbox etc) on iOS platform. Only raster tiles. All ok, but I have one problem: user can touch any point on screen (this is anchor point for rotation and scale). But does not work. Now I have modelView matrix, and every frame i updating this matrix with deltas (delta scale, delta rotation, delta translation). All work fine, but i can’t control animation of camera (I can only reset matrix and translate). When I trying control transform (without deltas), and every frame reset, translate, rotate, scale - all just twitches. And I have one question: How I can control transform (cumulate) with anchor point? Every frame now i do (based on gestures):

  • (void)tick {
    glOrthof(0, screenBounds.size.width, screenBounds.size.height, 0, -1, 1);


    GLKMatrix4 invModelView = GLKMatrix4Invert(modelView, nil);
    GLKVector4 anchorInCC = GLKMatrix4MultiplyVector4(invModelView, GLKVector4Make(cameraAnchor.x, cameraAnchor.y, 0, 1));

    glTranslatef(mCurrentTranslation.x, mCurrentTranslation.y, 0);
    mCurrentTranslation = GLKVector2Make(0, 0);
    glTranslatef(anchorInCC.x, anchorInCC.y, 0);

    if (mCurrentScale != 0) {
    mAccumulatedScale += mCurrentScale;
    mCurrentScale = 0.0;

      glGetFloatv(GL_MODELVIEW_MATRIX, modelView.m);
      modelView = GLKMatrix4Scale(modelView, mAccumulatedScale, mAccumulatedScale, 1);
      mAccumulatedScale = 1.0;


    glRotatef(mCurrentRotation * 180.0 / M_PI, 0, 0, 1);
    mCurrentRotation = 0.0;

    glTranslatef(-anchorInCC.x, -anchorInCC.y, 0);

    glGetFloatv(GL_MODELVIEW_MATRIX, modelView.m);

// Render geometry