Skip to content

Commit

Permalink
LwjglCanvas: initialize OpenCL for LWJGL2 (#1720)
Browse files Browse the repository at this point in the history
* Fixing OpenCL context null issue with LwjglCanvas. It is important that for Swing applications and with this fix, OpenCL won't be available in "simpleInitApp" and everything needs to be initialized inside the "simpleUpdate" with a boolean variable.

* Adding description to javaDoc
  • Loading branch information
AmiroooTheWalnut authored and stephengold committed Jan 10, 2022
1 parent 122b8c4 commit 0be4f6f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,9 @@ protected void destroyContext(){
* This is called:
* 1) When the context thread starts
* 2) Any time the canvas becomes displayable again.
* In the first call of this method, OpenGL context is not ready yet. Therefore, OpenCL context cannot be created.
* The second call of this method is done after "simpleInitApp" is called. Therefore, OpenCL won't be available in "simpleInitApp" if Canvas/Swing is used.
* To use OpenCL with Canvas/Swing, you need to use OpenCL in the rendering loop "simpleUpdate" and check for "context.getOpenCLContext()!=null".
*/
@Override
protected void createContext(AppSettings settings) {
Expand Down Expand Up @@ -477,7 +480,10 @@ protected void createContext(AppSettings settings) {
}else{
Display.create(acquirePixelFormat(false));
}

if (settings.isOpenCLSupport()) {
initOpenCL();
}

renderer.invalidateState();
}else{
// First create the pbuffer, if it is needed.
Expand Down

0 comments on commit 0be4f6f

Please sign in to comment.