コード例 #1
0
  @Override
  public void onDrawFrame(GL10 glUnused) {

    boolean barrelDistortionEnabled = mDisplayModeManager.isAntiDistortionEnabled();

    glCheck("MD360Renderer onDrawFrame 0");

    GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    glCheck("MD360Renderer onDrawFrame 1");
    int size = mDisplayModeManager.getVisibleSize();

    int width = (int) (this.mWidth * 1.0f / size);
    int height = mHeight;

    if (barrelDistortionEnabled) {
      // Barrel Distortion take over
      mBarrelDistortionPlugin.takeOver(mWidth, mHeight, size);
    }

    for (int i = 0; i < size; i++) {
      MD360Director director = mProjectionModeManager.getDirectors().get(i);
      GLES20.glViewport(width * i, 0, width, height);
      GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
      GLES20.glScissor(width * i, 0, width, height);

      Iterator<MDAbsPlugin> iterator = mPluginManager.getPlugins().iterator();
      while (iterator.hasNext()) {
        MDAbsPlugin plugin = iterator.next();
        plugin.setup(mContext);
        plugin.renderer(i, width, height, director);
      }

      GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
    }

    if (barrelDistortionEnabled) {
      // Barrel Distortion render
      for (int i = 0; i < size; i++) {

        GLES20.glViewport(width * i, 0, width, mHeight);
        GLES20.glEnable(GLES20.GL_SCISSOR_TEST);
        GLES20.glScissor(width * i, 0, width, mHeight);
        mBarrelDistortionPlugin.commit(i);
        GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
      }
    }

    // mFps.step();
  }
コード例 #2
0
  private MD360Renderer(Builder params) {
    mContext = params.context;
    mDisplayModeManager = params.displayModeManager;
    mProjectionModeManager = params.projectionModeManager;
    mPluginManager = params.pluginManager;

    mBarrelDistortionPlugin =
        new MDBarrelDistortionPlugin(mDisplayModeManager.getBarrelDistortionConfig());
    mPluginManager.add(mBarrelDistortionPlugin);
  }