I know processing P3d is built on top of joml…
So, how can I call joml’s openGL functions in processing?
I wanted to do some advanced culling tecniques like occlusion culling, and to do that, I need access opengl calls like “ARB_occlusion_query”
How can I do this?
If you use simple, older OpenGL functions that Processing happens to use, they may be part of Processing’s undocumented PGL layer. Browse through the source in https://github.com/processing/processing/tree/master/core/src/processing/opengl, specifically the PGL.java file. When the function you want inevitably isn’t there, you can get a raw GL context and call the functions directly from JOGL.
JOGL requires native format data arrays, so you have to construct them from Java arrays using the NIO functions.
Here is an example of what some of this looks like. You can call beginPGL()
either bare, which gets the OpenGL context from the default frame buffer, or call it on a PGraphics like I do below.
import java.nio.*;
import com.jogamp.opengl.*;
void drawPoints( PGraphics pg ) {
PJOGL pgl = (PJOGL) pg.beginPGL();
GL4 gl = pgl.gl.getGL4();
pointShdr.bind();
IntBuffer intBuffer = IntBuffer.allocate(1);
gl.glGetIntegerv( GL3.GL_VERTEX_ARRAY_BINDING, intBuffer );
int savedVaoId = intBuffer.get(0);
gl.glBindVertexArray( vaoId );
gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vboId );
gl.glDrawArrays( GL.GL_POINTS, 0, nCells );
gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0 );
gl.glBindVertexArray( savedVaoId );
pointShdr.unbind();
pg.endPGL();
}