Пример #1
0
 private void destroyOpenGL() {
   Shader.defaultShader.delete();
   Shader.plainShader.delete();
   Shader.distance.delete();
   Shader.waterMixdown.delete();
   terrain.delete();
   bunny.delete();
   bus.delete();
   plane.delete();
   skybox.delete();
   window.delete();
 }
Пример #2
0
  private void draw() {

    glEnable(GL_DEPTH_TEST);

    setupLightViewMatrix();
    lsvm = viewMatrix;
    distancesToLightSourceFBO.bindForWriting();

    GL11.glClearColor(1f, 0f, 0f, 1f);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    Shader.distance.enable();
    Shader.distance.setLightningPosition(lightSourcePosition);
    renderModels();
    Shader.distance.disable();
    distancesToLightSourceFBO.unbindForWriting();

    checkForGLError();

    setupViewMatrix(false);

    waterRefractionFBO.bindForWriting();
    renderClippedSceneWithLightning(-1000, 0);
    waterRefractionFBO.unbindForWriting();

    setupViewMatrix(true);
    waterReflectionFBO.bindForWriting();
    renderClippedSceneWithLightning(0, 1000);
    waterReflectionFBO.unbindForWriting();
    setupViewMatrix(false);

    renderClippedSceneWithLightning(-1000, 1000);

    Shader.waterMixdown.enable();
    Shader.waterMixdown.setTime((System.currentTimeMillis() % 16000) / 16000f);

    Shader.waterMixdown.setCameraPosition(cameraPos);
    Shader.waterMixdown.setLightningPosition(lightSourcePosition);

    Shader.waterMixdown.setProjectionMatrix(projectionMatrix);
    Shader.waterMixdown.setViewMatrix(viewMatrix);
    Shader.waterMixdown.setModelMatrix(identity);

    waterReflectionFBO.bindMOAR(0);
    waterRefractionFBO.bindMOAR(1);
    waterBumpMap.bindMOAR(2);

    plane.draw();

    Shader.waterMixdown.disable();

    Shader.plainShader.enable();

    Matrix4f projection = Matrix4f.orthographic(-3, 3, -3, 3, -1, 1);
    Shader.plainShader.setProjectionMatrix(projection);
    Shader.plainShader.setViewMatrix(identity);
    Shader.plainShader.setModelMatrix(new Matrix4f().translate(new Vector3f(-2, 2, 0)));

    Shader.plainShader.setClipAbove(1000);
    Shader.plainShader.setClipBelow(-1000);

    distancesToLightSourceFBO.bind();
    surface.draw();

    Shader.plainShader.disable();
  }