Skip to content

Commit 0be4f6f

Browse files
AmiroooTheWalnutstephengold
authored andcommitted
LwjglCanvas: initialize OpenCL for LWJGL2 (#1720)
* 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
1 parent 122b8c4 commit 0be4f6f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

jme3-lwjgl/src/main/java/com/jme3/system/lwjgl/LwjglCanvas.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,9 @@ protected void destroyContext(){
438438
* This is called:
439439
* 1) When the context thread starts
440440
* 2) Any time the canvas becomes displayable again.
441+
* In the first call of this method, OpenGL context is not ready yet. Therefore, OpenCL context cannot be created.
442+
* 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.
443+
* To use OpenCL with Canvas/Swing, you need to use OpenCL in the rendering loop "simpleUpdate" and check for "context.getOpenCLContext()!=null".
441444
*/
442445
@Override
443446
protected void createContext(AppSettings settings) {
@@ -477,7 +480,10 @@ protected void createContext(AppSettings settings) {
477480
}else{
478481
Display.create(acquirePixelFormat(false));
479482
}
480-
483+
if (settings.isOpenCLSupport()) {
484+
initOpenCL();
485+
}
486+
481487
renderer.invalidateState();
482488
}else{
483489
// First create the pbuffer, if it is needed.

0 commit comments

Comments
 (0)