コード例 #1
0
  /**
   * Draws a frame where the electron beam has been stretched out into a thin white horizontal line
   * that fades as it collapses inwards.
   *
   * @param stretch The stretch factor. 0.0 is maximum stretch / no fade, 1.0 is collapsed / maximum
   *     fade.
   */
  private void drawHStretch(float stretch) {
    // compute interpolation scale factor
    final float ag = scurve(stretch, 8.0f);
    if (DEBUG) {
      Slog.d(TAG, "drawHStretch: stretch=" + stretch + ", ag=" + ag);
    }

    if (stretch < 1.0f) {
      // bind vertex buffer
      GLES10.glVertexPointer(2, GLES10.GL_FLOAT, 0, mVertexBuffer);
      GLES10.glEnableClientState(GLES10.GL_VERTEX_ARRAY);

      // draw narrow fading white line
      setHStretchQuad(mVertexBuffer, mDisplayWidth, mDisplayHeight, ag, mSwapNeeded);
      GLES10.glColor4f(1.0f - ag * 0.75f, 1.0f - ag * 0.75f, 1.0f - ag * 0.75f, 1.0f);
      GLES10.glDrawArrays(GLES10.GL_TRIANGLE_FAN, 0, 4);

      // clean up
      GLES10.glDisableClientState(GLES10.GL_VERTEX_ARRAY);
    }
  }
コード例 #2
0
  /**
   * Draws a frame where the content of the electron beam is collapsing inwards upon itself
   * vertically with red / green / blue channels dispersing and eventually merging down to a single
   * horizontal line.
   *
   * @param stretch The stretch factor. 0.0 is no collapse, 1.0 is full collapse.
   */
  private void drawVStretch(float stretch) {
    // compute interpolation scale factors for each color channel
    final float ar = scurve(stretch, 7.5f);
    final float ag = scurve(stretch, 8.0f);
    final float ab = scurve(stretch, 8.5f);
    if (DEBUG) {
      Slog.d(TAG, "drawVStretch: stretch=" + stretch + ", ar=" + ar + ", ag=" + ag + ", ab=" + ab);
    }

    // set blending
    GLES10.glBlendFunc(GLES10.GL_ONE, GLES10.GL_ONE);
    GLES10.glEnable(GLES10.GL_BLEND);

    // bind vertex buffer
    GLES10.glVertexPointer(2, GLES10.GL_FLOAT, 0, mVertexBuffer);
    GLES10.glEnableClientState(GLES10.GL_VERTEX_ARRAY);

    // set-up texturing
    GLES10.glDisable(GLES10.GL_TEXTURE_2D);
    GLES10.glEnable(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);

    // bind texture and set blending for drawing planes
    GLES10.glBindTexture(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, mTexNames[0]);
    GLES10.glTexEnvx(
        GLES10.GL_TEXTURE_ENV,
        GLES10.GL_TEXTURE_ENV_MODE,
        mMode == MODE_WARM_UP ? GLES10.GL_MODULATE : GLES10.GL_REPLACE);
    GLES10.glTexParameterx(
        GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES10.GL_TEXTURE_MAG_FILTER, GLES10.GL_LINEAR);
    GLES10.glTexParameterx(
        GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES10.GL_TEXTURE_MIN_FILTER, GLES10.GL_LINEAR);
    GLES10.glTexParameterx(
        GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES10.GL_TEXTURE_WRAP_S, GLES10.GL_CLAMP_TO_EDGE);
    GLES10.glTexParameterx(
        GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GLES10.GL_TEXTURE_WRAP_T, GLES10.GL_CLAMP_TO_EDGE);
    GLES10.glEnable(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
    GLES10.glTexCoordPointer(2, GLES10.GL_FLOAT, 0, mTexCoordBuffer);
    GLES10.glEnableClientState(GLES10.GL_TEXTURE_COORD_ARRAY);

    // draw the red plane
    setVStretchQuad(mVertexBuffer, mDisplayWidth, mDisplayHeight, ar, mSwapNeeded);
    GLES10.glColorMask(true, false, false, true);
    GLES10.glDrawArrays(GLES10.GL_TRIANGLE_FAN, 0, 4);

    // draw the green plane
    setVStretchQuad(mVertexBuffer, mDisplayWidth, mDisplayHeight, ag, mSwapNeeded);
    GLES10.glColorMask(false, true, false, true);
    GLES10.glDrawArrays(GLES10.GL_TRIANGLE_FAN, 0, 4);

    // draw the blue plane
    setVStretchQuad(mVertexBuffer, mDisplayWidth, mDisplayHeight, ab, mSwapNeeded);
    GLES10.glColorMask(false, false, true, true);
    GLES10.glDrawArrays(GLES10.GL_TRIANGLE_FAN, 0, 4);

    // clean up after drawing planes
    GLES10.glDisable(GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
    GLES10.glDisableClientState(GLES10.GL_TEXTURE_COORD_ARRAY);
    GLES10.glColorMask(true, true, true, true);

    // draw the white highlight (we use the last vertices)
    if (mMode == MODE_COOL_DOWN) {
      GLES10.glColor4f(ag, ag, ag, 1.0f);
      GLES10.glDrawArrays(GLES10.GL_TRIANGLE_FAN, 0, 4);
    }

    // clean up
    GLES10.glDisableClientState(GLES10.GL_VERTEX_ARRAY);
    GLES10.glDisable(GLES10.GL_BLEND);
  }