How to resolve GL2 class does not exist?

edited March 2017 in GLSL / Shaders

I am trying to upgrade from Processing 2 to Processing 3. I am getting an error that the class GL2 does not exist. Do I need to install JOGL. If so, then how to install it for mac OS Sierra?



  • processing 3 uses, iirc, jogamp libraries, not jogl (i think they are the roughly the same thing, just renamed, updated). but you don't usually need to specify imports for that stuff, it's automatic.

    post a runnable code sample that shows the problem.

  • mmkmmk
    edited March 2017
    void drawsketch {
      PGL pgl;
      pgl = beginPGL();
      GL2 gl = ((PJOGL)pgl).gl.getGL2();
  • What do you then do with gl2?

  • if i need raw opengl in v3 for, say, additive blending, i use the following

    // before setup
    import processing.opengl.*;
    import com.jogamp.opengl.*;  // new jogl - 3.0b7
    // in draw
    GL gl = ((PJOGL)beginPGL()).gl.getGL();
    // eg additive blending
    gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE);
  • (ah, ok, that's GL and not GL2. and is very similar to yours)

  • this should be fine

    GL2 gl2 = ((PJOGL)beginPGL()).gl.getGL2();

    mine compiles and runs but tells me it's not a GL2 implementation.

  • mmkmmk
    edited March 2017
    import java.nio.ByteBuffer;
    import java.nio.ByteOrder;
    import java.nio.FloatBuffer;
    import java.nio.IntBuffer;
    import com.jogamp.opengl.GL;
    import com.jogamp.opengl.GL2ES2;

    This solved the issue. But now I am getting a new error.

    The static field GL_LINE should be used in a static way. This is the code snippet for its use.

    gl.glBegin(gl.GL_LINES); // start drawing points

    Please guide me as to how to resolve this.

  • gl.GL_LINES should be GL.GL_LINES.

    It's static so you need to use the class and bit the variable.

Sign In or Register to comment.