From 5a5ffdc2ae6f80993dabff1431e84e74e42dc6df Mon Sep 17 00:00:00 2001 From: Julien Gouesse Date: Wed, 18 May 2016 21:11:51 +0200 Subject: [PATCH] First attempt of fix for the issue #490 --- .../jme3/system/jogl/JoglOffscreenBuffer.java | 32 +++++++++++++------ 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java index 54fa3b552..c912c4f9e 100644 --- a/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java +++ b/jme3-jogl/src/main/java/com/jme3/system/jogl/JoglOffscreenBuffer.java @@ -37,14 +37,13 @@ import com.jme3.input.MouseInput; import com.jme3.input.TouchInput; import com.jme3.input.dummy.DummyKeyInput; import com.jme3.input.dummy.DummyMouseInput; +import com.jme3.system.AppSettings; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import com.jogamp.opengl.GL; import com.jogamp.opengl.GLCapabilities; -import com.jogamp.opengl.GLContext; import com.jogamp.opengl.GLDrawableFactory; import com.jogamp.opengl.GLOffscreenAutoDrawable; import com.jogamp.opengl.GLProfile; @@ -61,14 +60,19 @@ public class JoglOffscreenBuffer extends JoglContext implements Runnable { private GLCapabilities caps; protected void initInThread(){ - GL gl = GLContext.getCurrentGL(); - if (!gl.hasFullFBOSupport()){ - logger.severe("Offscreen surfaces are not supported."); - return; + // not necessary as JOGL can create an offscreen buffer even without full FBO support +// if (!GLContext.getCurrent().hasFullFBOSupport()){ +// logger.severe("Offscreen surfaces are not supported."); +// return; +// } + final GLProfile profile; + if (settings.getRenderer().equals(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE)) { + profile = GLProfile.getMaxProgrammable(true); + } else { + profile = GLProfile.getMaxFixedFunc(true); } - + caps = new GLCapabilities(profile); int samples = getNumSamplesToUse(); - caps = new GLCapabilities(GLProfile.getMaxFixedFunc(true)); caps.setHardwareAccelerated(true); caps.setDoubleBuffered(true); caps.setStencilBits(settings.getStencilBits()); @@ -77,7 +81,7 @@ public class JoglOffscreenBuffer extends JoglContext implements Runnable { caps.setSampleBuffers(true); caps.setNumSamples(samples); - offscreenDrawable = GLDrawableFactory.getFactory(GLProfile.getMaxFixedFunc(true)).createOffscreenAutoDrawable(null, caps, null, width, height); + offscreenDrawable = GLDrawableFactory.getFactory(profile).createOffscreenAutoDrawable(null, caps, null, width, height); offscreenDrawable.display(); @@ -88,6 +92,16 @@ public class JoglOffscreenBuffer extends JoglContext implements Runnable { super.internalCreate(); listener.initialize(); } + + @Override + protected void initContextFirstTime(){ + offscreenDrawable.getContext().makeCurrent(); + try { + super.initContextFirstTime(); + } finally { + offscreenDrawable.getContext().release(); + } + } protected boolean checkGLError(){ //FIXME