예제 #1
0
  private void renderLines() {
    if (phenixLineProgram != null) {
      if (!phenixLineProgram.use()) {
        return;
      }

      float angle =
          360.0f * getTimeDeltaByScale((long) (1 * 50000L / speedFactor / rotationSpeedFactor));
      Matrix.setRotateM(M_matrix, 0, angle, 0, 0, 1.0f);

      Matrix.multiplyMM(MVP_matrix, 0, V_matrix, 0, M_matrix, 0);
      Matrix.multiplyMM(MVP_matrix, 0, P_matrix, 0, MVP_matrix, 0);

      float delta = getTimeDeltaByScale((long) (1 * 25000L / speedFactor));

      lineVertices.bind(phenixLineProgram, "aPosition", null);

      GLES20.glUniformMatrix4fv(
          phenixLineProgram.getUniformLocation("uMVPMatrix"), 1, false, MVP_matrix, 0);

      GLES20.glUniform1f(phenixLineProgram.getUniformLocation("uDelta"), delta);
      GLES20.glUniform1f(
          phenixLineProgram.getUniformLocation("uBrightness"), brightness * brightnessFactor);
      GLES20.glUniform3f(
          phenixLineProgram.getUniformLocation("uColor"),
          linesColorRed,
          linesColorGreen,
          linesColorBlue);

      GLES20.glEnable(GLES20.GL_BLEND);
      GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE);
      GLES20.glLineWidth(lineWidth * lineWidthFactor);

      lineVertices.draw(GLES20.GL_LINES, 0, MOVING_LINE_COUNT);

      GLES20.glUniform1f(phenixLineProgram.getUniformLocation("uDelta"), 0.0f);

      lineVertices.draw(GLES20.GL_LINES, MOVING_LINE_COUNT, STALE_LINE_COUNT);

      GLES20.glDisable(GLES20.GL_BLEND);

      lineVertices.unbind(phenixLineProgram, "aPosition", null);
    }
  }
예제 #2
0
  private void renderBlurTexture(int textureIndex) {
    if (postProgram.use()) {
      renderTextures[textureIndex].bind(GLES20.GL_TEXTURE0, postProgram, "sTexture");
      quadVertices.bind(postProgram, "aPosition", "aTextureCoord");

      GLES20.glUniform1f(postProgram.getUniformLocation("uBlur"), blur * blurFactor);

      GLES20.glUniformMatrix4fv(
          postProgram.getUniformLocation("uMVPMatrix"), 1, false, Q_matrix, 0);

      GLES20.glEnable(GLES20.GL_BLEND);
      GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE);

      quadVertices.draw(GLES20.GL_TRIANGLE_STRIP);

      GLES20.glDisable(GLES20.GL_BLEND);

      quadVertices.unbind(postProgram, "aPosition", "aTextureCoord");

      renderTextures[textureIndex].unbind(GLES20.GL_TEXTURE0);
    }
  }