コード例 #1
0
ファイル: Example08.java プロジェクト: fatore/jopengl
  @Override
  public void display() {
    gl.glClear(GL3.GL_COLOR_BUFFER_BIT | GL3.GL_DEPTH_BUFFER_BIT);

    // Calculate the model matrix ...
    modelMatrix.loadIdentity();
    // ... by rotating the cube.
    modelMatrix.rotate(Maths.degToRad(15), new float[] {1, 0, 0});
    modelMatrix.rotate(Maths.degToRad(angle), new float[] {0, 1, 0});

    // MV = V * M
    modelViewMatrix.multiply(viewMatrix, modelMatrix);
    modelViewMatrix.bind();

    // Again, extract the normal matrix.
    // Remember, so far the model view matrix (rotation part) is orthogonal.
    normalMatrix.extract(modelViewMatrix);
    normalMatrix.bind();

    // Extract the rotation part of the view matrix.
    inverseViewMatrix.extract(viewMatrix);

    // Pass this matrix to the shader with the transpose flag.
    // As the view matrix is orthogonal, the transposed is the inverse view matrix.
    inverseViewMatrix.bind(true);

    cubeMap.bind();

    model.bind();
    model.draw(GL3.GL_TRIANGLES);

    gl.glFlush();

    update();
  }