Пример #1
0
  private void draw() {

    GLState.setClearColor(mClearColor);

    gl.depthMask(true);
    gl.stencilMask(0xFF);

    gl.clear(GL.COLOR_BUFFER_BIT | GL.DEPTH_BUFFER_BIT | GL.STENCIL_BUFFER_BIT);

    gl.depthMask(false);
    gl.stencilMask(0);

    GLState.test(false, false);
    GLState.blend(false);
    GLState.bindTex2D(-1);
    GLState.useProgram(-1);
    GLState.bindElementBuffer(-1);
    GLState.bindVertexBuffer(-1);

    mViewport.setFrom(mMap);

    if (GLAdapter.debugView) {
      /* modify this to scale only the view, to see
       * which tiles are rendered */
      mViewport.mvp.setScale(0.5f, 0.5f, 1);
      mViewport.viewproj.multiplyLhs(mViewport.mvp);
      mViewport.proj.multiplyLhs(mViewport.mvp);
    }

    /* update layers */
    LayerRenderer[] layers = mMap.layers().getLayerRenderer();

    for (int i = 0, n = layers.length; i < n; i++) {
      LayerRenderer renderer = layers[i];

      if (!renderer.isInitialized) {
        renderer.setup();
        renderer.isInitialized = true;
      }

      renderer.update(mViewport);

      if (renderer.isReady) renderer.render(mViewport);

      if (GLAdapter.debug) GLUtils.checkGlError(renderer.getClass().getName());
    }

    if (GLUtils.checkGlOutOfMemory("finish")) {
      BufferObject.checkBufferUsage(true);
      // FIXME also throw out some textures etc
    }
  }