コード例 #1
0
  /*
   * Draw function - called for every frame
   */
  public void onDrawFrame(GL10 glUnused) {
    // Ignore the passed-in GL10 interface, and use the GLES20
    // class's static methods instead.
    GLES20.glClearColor(.0f, .0f, .0f, 1.0f);
    GLES20.glClear(GLES20.GL_DEPTH_BUFFER_BIT | GLES20.GL_COLOR_BUFFER_BIT);

    GLES20.glUseProgram(0);
    // the current shader
    Shader shader = _shaders[this._currentShader]; // PROBLEM!
    int program = shader.get_program();

    // Start using the shader
    GLES20.glUseProgram(program);
    checkGlError("glUseProgram");

    setLight(program);
    drawCar(program, new float[] {0.0f, 5.0f, 20.0f});
    drawCar2(program, new float[] {-10.0f, 5.0f, 10.0f});
    drawCar2(program, new float[] {-5.0f, 5.0f, -10.0f});
    drawCar2(program, new float[] {10.0f, 5.0f, 0.0f});
    drawCar2(program, new float[] {50.0f, 5.0f, 15.0f});
    drawRoad(program);

    // eye position
    GLES20.glUniform3fv(
        GLES20.glGetUniformLocation(program, "eyePos") /*shader.eyeHandle*/, 1, eyePos, 0);
  }