@Override
 public void init(GLAutoDrawable drawable) {
   defAutoSwapMode = drawable.getAutoSwapBufferMode();
   swapBuffersBeforeRead =
       GLDrawableUtil.swapBuffersBeforeRead(drawable.getChosenGLCapabilities());
   drawable.setAutoSwapBufferMode(!swapBuffersBeforeRead);
 }
Exemple #2
0
  public void init(GLAutoDrawable drawable) {
    drawable.setAutoSwapBufferMode(false);

    GL2ES2 gl = drawable.getGL().getGL2ES2();
    System.err.println("Entering initialization");
    System.err.println("GL_VERSION=" + gl.glGetString(gl.GL_VERSION));
    System.err.println("GL_EXTENSIONS:");
    System.err.println("  " + gl.glGetString(gl.GL_EXTENSIONS));

    pmvMatrix = new PMVMatrix();

    pmod.initShaderState(gl);
    st = ShaderState.getCurrent();

    // Push the 1st uniform down the path
    st.glUseProgram(gl, true);

    pmvMatrix.glMatrixMode(pmvMatrix.GL_PROJECTION);
    pmvMatrix.glLoadIdentity();
    pmvMatrix.glMatrixMode(pmvMatrix.GL_MODELVIEW);
    pmvMatrix.glLoadIdentity();

    if (!st.glUniform(gl, new GLUniformData("mgl_PMVMatrix", 4, 4, pmvMatrix.glGetPMvMatrixf()))) {
      throw new GLException("Error setting PMVMatrix in shader: " + st);
    }

    // OpenGL Render Settings
    gl.glClearColor(0, 0, 0, 1);
    gl.glEnable(GL2ES2.GL_DEPTH_TEST);

    st.glUseProgram(gl, false);

    // Let's show the completed shader state ..
    System.out.println(st);
  }
 @Override
 public void dispose(GLAutoDrawable drawable) {
   drawable.setAutoSwapBufferMode(defAutoSwapMode);
 }