Re: Can JOGL be used without requiring GLAutoDrawable instances?
Posted by
xghost on
Jul 26, 2015; 8:06pm
URL: https://forum.jogamp.org/Can-JOGL-be-used-without-requiring-GLAutoDrawable-instances-tp4034953p4034975.html
Sven Gothel wrote
I would not recommend this path, since it requires detail knowledge
about the OpenGL and windowing system lifecycle.
All of the latter is handled when using the 'assisted' API model.
That makes sense. Thanks for the clarification.
Sven Gothel wrote
Well the above will work iff the desired OpenGL GLContext
is current. Otherwise a GLException is thrown or you receive
the wrong GLContext (if many different are in use).
Note: GLContext.getCurrent() will return null if none is current.
In short: Yes it can work, given above constraints.
Yes, the javadocs seemed to make this point, but It's good to see that I'm not about to cause a massive problem in the long-term, AFAIK. The application is expected to have a single window and OpenGL context, so I don't anticipate this becoming a problem.
Sven Gothel wrote
However, it is still not the desired safe and recommended way to handle
to handle this task.
What would your recommendation be for the kind of task I'm trying to achieve?
For example, one of my GLSL uniform classes looks as shown below. If you notice the 'set' method, it simply allows the client to call/set the value without making the GL instance visible. If there's a safer and better way to achieve this kind of goal, I'm open to it. (Yes, I already refactored the code to use JOGL and I have things working, which is why the code below is no longer showing the static call to LWJGL3.)
class GLSLFloatProgramUniform1 extends GLSLProgramUniform<Float> implements GpuShaderProgram.Input<Float> {
// ...
@Override
public void set(Float value) {
GL4 gl = GLContext.getCurrentGL().getGL4();
gl.glUniform1f(location, value);
}
// ...
}
Read all of it, but I didn't find the question you seemed to want me to read about.
Sven Gothel wrote
In the end .. it is your design decision, of course!
Cheers, Sven
Yup, just trying to make an informed decision so I won't regret it in hindsight :)
Thanks again,
-x