Login  Register

Can JOGL be used without requiring GLAutoDrawable instances?

Posted by xghost on Jul 23, 2015; 5:50am
URL: https://forum.jogamp.org/Can-JOGL-be-used-without-requiring-GLAutoDrawable-instances-tp4034953.html

Hi all,

I'm currently working on a project to develop a relatively small framework with the goal of supporting game development efforts for students in a course. The scope of this project is an OpenGL-based renderer and a 3D scene graph, and must be written in Java. (That's the course pre-req. for students.)

I've been using JOGL for a while and have also played around a bit with LWJGW3 --yes, I dare disturb you by mentioning a competitor :D--

There're some things I'd like to do, but I'm finding the requirement to have a GLAutoDrawable object a bit of a hassle. For example, I want to hide the library dependency from clients (i.e. clients use my interface, not JOGL directly). However, if/when needs to use a shader object (one I make available, not JOGL's ShaderProgram class), they'd need to be able to have a reference to the gl object for it to work, leaking the fact that I'm using JOGL through the interface.

More concretely, code that looks like this example below:

    program.<Float> getInput("position_x").set(0.5f);

would have to look, say, like this:

    GL4 gl = ... // get an drawable.getGL(), etc...
    program.<Float> getInput("position_x").set(gl, 0.5f);

...which is problematic; I want to avoid leaking JOGL 'knowledge' to the client program.

For comparison, the static nature of LWJGL3 allows me use OpenGL functions at any point, without the requirement for an object instance like the GLAutoDrawable or implementing the GLEventListener interface --though it introduces other problems by having its own window mgmt API with GLFW, which causes similar 'leakage' on the input/event management side of the equation (i.e. cannot implement interfaces like MouseListener, KeyListener, etc).

Is there some way in which  JOGL can be used to make OpenGL calls (e.g. glUseProgram(...)) statically without GLAutoDrawable instance inside void display(GLAutoDrawable), or equivalent? I want to be able to make OpenGL calls anytime/anywhere.

I hope this made sense. You should try taking a look at this post where I went into a bit more detail in some areas, if you feel you need clarification.

I'd appreciate concrete suggestions, especially if you can provide actual examples what would illustrate your point more clearly.

Thanks in advance,

-x

PS: BTW I've thought about using LWJGL3 + JOGL simultaneously. Is this even a good idea, or just a bomb of problems waiting go off? For example, if a GLCanvas were to be added to a JFrame and then, instead of using autodrawables in the display(...) override, I end up using OpenGL calls from the LWJGL3 instead. Is this even possible in principle as long as the GLContext is current?