Scirenderer: use JOGL 2.2.X API (fix bug 13586) 95/15395/4
Clément DAVID [Fri, 17 Oct 2014 07:10:05 +0000 (09:10 +0200)]
Change-Id: Ifa2222190af6c5047f5b61b3a7b273ca4c10d4b6

scilab/CHANGES_5.5.X
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/JoGLCanvas.java

index d1eb041..3358a58 100644 (file)
@@ -23,11 +23,19 @@ Removed Functions
 * relocate_handle removed.
 
 
+Compilation
+===========
+
+* Required version of JOGL updated to 2.2.4 (See Bug #13586).
+
+
 Scilab Bug Fixes
 ================
 
 * Bug #13549 fixed - Slider uicontrols triggered three callbacks instead of one.
 
+* Bug #13586 fixed - Scilab compilation failed with recent versions of JoGL package.
+
 * Bug #13605 fixed - harmean returned an inverted result when called with parameters "r" or "c".
 
 * Bug #13673 fixed - Anti-aliasing of xpoly marks did not render correctly.
index 96c0f92..8752460 100644 (file)
@@ -19,12 +19,14 @@ import org.scilab.forge.scirenderer.implementation.jogl.renderer.JoGLRendererMan
 import org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager;
 import org.scilab.forge.scirenderer.picking.PickingManager;
 
+import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
 import com.jogamp.opengl.util.awt.ImageUtil;
-import com.jogamp.opengl.util.awt.Screenshot;
+
 import java.awt.Dimension;
 import java.awt.image.BufferedImage;
 import java.lang.reflect.InvocationTargetException;
 import java.util.concurrent.Semaphore;
+
 import javax.media.opengl.DebugGL2;
 import javax.media.opengl.GL2;
 import javax.media.opengl.GLAutoDrawable;
@@ -33,7 +35,7 @@ import javax.media.opengl.GLContext;
 import javax.media.opengl.GLDrawableFactory;
 import javax.media.opengl.GLEventListener;
 import javax.media.opengl.GLException;
-import javax.media.opengl.GLPbuffer;
+import javax.media.opengl.GLOffscreenAutoDrawable;
 import javax.media.opengl.GLProfile;
 import javax.swing.SwingUtilities;
 
@@ -154,17 +156,17 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
 
     @Override
     public int getWidth() {
-        return autoDrawable.getWidth();
+        return autoDrawable.getSurfaceWidth();
     }
 
     @Override
     public int getHeight() {
-        return autoDrawable.getHeight();
+        return autoDrawable.getSurfaceHeight();
     }
 
     @Override
     public Dimension getDimension() {
-        return new Dimension(autoDrawable.getWidth(), autoDrawable.getHeight());
+        return new Dimension(autoDrawable.getSurfaceWidth(), autoDrawable.getSurfaceHeight());
     }
 
     @Override
@@ -244,14 +246,16 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
 
         if (SwingUtilities.isEventDispatchThread()) {
             context.makeCurrent();
-            image[0] = Screenshot.readToBufferedImage(autoDrawable.getWidth(), autoDrawable.getHeight());
+            AWTGLReadBufferUtil buffer = new AWTGLReadBufferUtil(GLProfile.getDefault(), true);
+            image[0] = buffer.readPixelsToBufferedImage(getGl(), 0, 0, autoDrawable.getSurfaceWidth(), autoDrawable.getSurfaceHeight(), false);
             context.release();
         } else {
             try {
                 SwingUtilities.invokeAndWait(new Runnable() {
                     public void run() {
                         context.makeCurrent();
-                        image[0] = Screenshot.readToBufferedImage(autoDrawable.getWidth(), autoDrawable.getHeight());
+                        AWTGLReadBufferUtil buffer = new AWTGLReadBufferUtil(GLProfile.getDefault(), true);
+                        image[0] = buffer.readPixelsToBufferedImage(getGl(), 0, 0, autoDrawable.getSurfaceWidth(), autoDrawable.getSurfaceHeight(), false);
                         context.release();
                     }
                 });
@@ -271,7 +275,7 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
      */
     public void destroy() {
         if (isOffscreen) {
-            ((GLPbuffer) autoDrawable).destroy();
+            ((GLOffscreenAutoDrawable) autoDrawable).destroy();
         }
         try {
             isValid = false;
@@ -289,9 +293,11 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
      */
     private static GLAutoDrawable getOffscreenDrawable(int width, int height) {
         GLDrawableFactory factory = GLDrawableFactory.getDesktopFactory();
+
         GLCapabilities capabilities = new GLCapabilities(GLProfile.getDefault());
+        capabilities.setPBuffer(true);
 
-        return factory.createGLPbuffer(null, capabilities, null, width, height, null);
+        return factory.createOffscreenAutoDrawable(null, capabilities, null, width, height);
     }
 
     // Implementation of function from GLEventListener.