Revert "Enable 8x anti aliasing through JoGL native multisampling." 99/14299/2
Vincent COUVERT [Wed, 2 Apr 2014 11:46:30 +0000 (13:46 +0200)]
This reverts commit f46ec729e85525f61233e8dcb0229b2a2321181d.

Change-Id: Ibaebabce6bd94a322799dc797f40827554540087

scilab/CHANGES_5.5.X
scilab/modules/gui/src/java/org/scilab/modules/gui/bridge/canvas/SwingScilabCanvasImpl.java
scilab/modules/scirenderer/src/org/scilab/forge/scirenderer/implementation/jogl/JoGLCanvas.java

index dd632ec..b7a43e8 100644 (file)
@@ -1988,10 +1988,6 @@ Known incompatibilities
 * Extracting children from an empty matrix of handles now returns an error.
   For example: f=gcf(); f.children(1).children.children returns an error.
 
-* Figure anti_aliasing property behavior changed:
-  - "off": No anti-aliasing activated on the figure.
-  - "2x", "4x", "8x", "16x": anti-aliasing activated using 8-buffers multi-sampling.
-
 
 Scilab Bug Fixes
 ================
index 622dab3..3c5fc99 100644 (file)
@@ -201,10 +201,6 @@ public class SwingScilabCanvasImpl {
     private final class SafeGLJPanel extends GLJPanel {
         private static final long serialVersionUID = -6166986369022555750L;
 
-        public SafeGLJPanel(GLCapabilities caps) {
-            super(caps);
-        }
-
         public void display() {
             try {
                 super.display();
@@ -234,10 +230,6 @@ public class SwingScilabCanvasImpl {
     */
     private final class SafeGLCanvas extends GLCanvas {
         private static final long serialVersionUID = -3315164314205693678L;
-
-        public SafeGLCanvas(GLCapabilities caps) {
-            super(caps);
-        }
     }
 
     private static SwingScilabCanvasImpl me = null;
@@ -251,13 +243,11 @@ public class SwingScilabCanvasImpl {
     }
 
     public Component createOpenGLComponent() {
-        GLCapabilities caps = new GLCapabilities(GLProfile.getDefault());
-        caps.setSampleBuffers(true);
-        caps.setNumSamples(8);
         if (enableGLCanvas) {
-            return new SafeGLCanvas(caps);
+            return new SafeGLCanvas();
+        } else {
+            return new SafeGLJPanel();
         }
-        return new SafeGLJPanel(caps);
     }
 
     public SwingScilabCanvasImpl() {}
index 0a13910..96c0f92 100644 (file)
 
 package org.scilab.forge.scirenderer.implementation.jogl;
 
+import org.scilab.forge.scirenderer.Canvas;
+import org.scilab.forge.scirenderer.Drawer;
+import org.scilab.forge.scirenderer.implementation.jogl.buffers.JoGLBuffersManager;
+import org.scilab.forge.scirenderer.implementation.jogl.picking.JoGLPickingManager;
+import org.scilab.forge.scirenderer.implementation.jogl.renderer.JoGLRendererManager;
+import org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager;
+import org.scilab.forge.scirenderer.picking.PickingManager;
+
+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;
@@ -28,16 +37,6 @@ import javax.media.opengl.GLPbuffer;
 import javax.media.opengl.GLProfile;
 import javax.swing.SwingUtilities;
 
-import org.scilab.forge.scirenderer.Canvas;
-import org.scilab.forge.scirenderer.Drawer;
-import org.scilab.forge.scirenderer.implementation.jogl.buffers.JoGLBuffersManager;
-import org.scilab.forge.scirenderer.implementation.jogl.picking.JoGLPickingManager;
-import org.scilab.forge.scirenderer.implementation.jogl.renderer.JoGLRendererManager;
-import org.scilab.forge.scirenderer.implementation.jogl.texture.JoGLTextureManager;
-import org.scilab.forge.scirenderer.picking.PickingManager;
-
-import com.jogamp.opengl.util.awt.Screenshot;
-
 /**
  * JoGL implementation of a Canvas.
  *
@@ -308,15 +307,38 @@ public final class JoGLCanvas implements Canvas, GLEventListener {
             if (mainDrawer != null) {
                 gl.glEnable(GL2.GL_DEPTH_TEST);
                 gl.glDepthFunc(GL2.GL_LEQUAL); // Set to less equal to allow last drawn object to be on the top.
-                if ((antiAliasingLevel > 0) && (antiAliasingLevel < 5)) {
-                    gl.glEnable(GL2.GL_MULTISAMPLE);
+
+                if ((antiAliasingLevel > 0) && (antiAliasingLevel < 5) && (drawingTools.getGLCapacity().isAccumulationBufferPresent())) {
+                    org.scilab.forge.scirenderer.renderer.Renderer renderer = rendererManager.createRenderer();
+                    renderer.setDrawer(mainDrawer);
+
+                    double[][] jitter = ANTI_ALIASING_JITTER[antiAliasingLevel];
+                    Dimension dimension = getDimension();
+                    gl.glClear(GL2.GL_ACCUM_BUFFER_BIT);
+                    for (double[] aJitter : jitter) {
+                        drawingTools.glSynchronize(gl);
+
+                        gl.glMatrixMode(GL2.GL_PROJECTION);
+                        gl.glLoadIdentity();
+                        gl.glTranslated(aJitter[0] / dimension.getWidth(), aJitter[1] / dimension.getHeight(), 0.);
+
+                        gl.glClear(GL2.GL_DEPTH_BUFFER_BIT);
+                        rendererManager.draw(drawingTools, renderer);
+                        //mainDrawer.draw(drawingTools);
+                        gl.glReadBuffer(GL2.GL_BACK);
+                        gl.glAccum(GL2.GL_ACCUM, 1f / jitter.length);
+                    }
+
+                    rendererManager.dispose(drawingTools, renderer);
+
+                    gl.glDrawBuffer(GL2.GL_BACK);
+                    gl.glAccum(GL2.GL_RETURN, 1.0f);
                 } else {
-                    gl.glDisable(GL2.GL_MULTISAMPLE);
+                    gl.glMatrixMode(GL2.GL_PROJECTION);
+                    gl.glLoadIdentity();
+                    gl.glClear(GL2.GL_DEPTH_BUFFER_BIT);
+                    mainDrawer.draw(drawingTools);
                 }
-                gl.glMatrixMode(GL2.GL_PROJECTION);
-                gl.glLoadIdentity();
-                gl.glClear(GL2.GL_DEPTH_BUFFER_BIT);
-                mainDrawer.draw(drawingTools);
             }
 
             pickingManager.glConsume(drawingTools);