mirror of https://github.com/rusefi/jzy3d-api.git
Fixed OffscreenCanvas regression.
Fixed test failure for ChartTest.
This commit is contained in:
parent
00a7430821
commit
10a12e25c5
|
@ -25,6 +25,7 @@ import org.jzy3d.chart.controllers.keyboard.screenshot.ScreenshotKeyControllerNe
|
|||
import org.jzy3d.chart.controllers.mouse.camera.CameraMouseController;
|
||||
import org.jzy3d.chart.controllers.mouse.camera.CameraMouseControllerNewt;
|
||||
import org.jzy3d.chart.controllers.mouse.camera.ICameraMouseController;
|
||||
import org.jzy3d.global.Settings;
|
||||
import org.jzy3d.maths.BoundingBox3d;
|
||||
import org.jzy3d.maths.Coord3d;
|
||||
import org.jzy3d.maths.Utils;
|
||||
|
@ -105,26 +106,7 @@ public class ChartComponentFactory implements IChartComponentFactory {
|
|||
*/
|
||||
@Override
|
||||
public ICanvas newCanvas(Scene scene, Quality quality, String chartType, GLCapabilities capabilities){
|
||||
// if("awt".compareTo(chartType)==0)
|
||||
// return new CanvasAWT(this, scene, quality, capabilities);
|
||||
// else if("swing".compareTo(chartType)==0)
|
||||
// return new CanvasSwing(this, scene, quality, capabilities);
|
||||
// else if("newt".compareTo(chartType)==0)
|
||||
// return new CanvasNewt(this, scene, quality, capabilities);
|
||||
// else if(chartType.startsWith("offscreen")){
|
||||
// Pattern pattern = Pattern.compile("offscreen,(\\d+),(\\d+)");
|
||||
// Matcher matcher = pattern.matcher(chartType);
|
||||
// if(matcher.matches()){
|
||||
// int width = Integer.parseInt(matcher.group(1));
|
||||
// int height = Integer.parseInt(matcher.group(2));
|
||||
// return new OffscreenCanvas(this, scene, quality, GLProfile.getDefault(), width, height);
|
||||
// }
|
||||
// else
|
||||
// return new OffscreenCanvas(this, scene, quality, GLProfile.getDefault(), 500, 500);
|
||||
// }
|
||||
// else
|
||||
// throw new RuntimeException("unknown chart type:" + chartType);
|
||||
return initializeCanvas(scene, quality, chartType, capabilities, false, false);
|
||||
return initializeCanvas(scene, quality, chartType, capabilities, false, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -222,7 +204,7 @@ public class ChartComponentFactory implements IChartComponentFactory {
|
|||
return new CanvasNewt(this,scene, quality, capabilities, traceGL, debugGL);
|
||||
case offscreen:
|
||||
Dimension dimension = getCanvasDimension(windowingToolkit);
|
||||
return new OffscreenCanvas(this, scene, quality, GLProfile.getDefault(), dimension.width, dimension.height, traceGL, debugGL);
|
||||
return new OffscreenCanvas(this, scene, quality, capabilities, dimension.width, dimension.height, traceGL, debugGL);
|
||||
default:
|
||||
throw new RuntimeException("unknown chart type:" + chartType);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.jzy3d.plot3d.rendering.canvas;
|
||||
|
||||
import com.jogamp.newt.opengl.GLWindow;
|
||||
import java.awt.event.KeyListener;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
|
@ -9,7 +8,6 @@ import java.awt.image.BufferedImage;
|
|||
|
||||
import javax.media.opengl.GL;
|
||||
import javax.media.opengl.GL2;
|
||||
import javax.media.opengl.GLAutoDrawable;
|
||||
import javax.media.opengl.GLCapabilities;
|
||||
import javax.media.opengl.GLDrawable;
|
||||
import javax.media.opengl.GLDrawableFactory;
|
||||
|
@ -23,16 +21,33 @@ import org.jzy3d.plot3d.rendering.view.View;
|
|||
|
||||
public class OffscreenCanvas implements ICanvas {
|
||||
|
||||
public OffscreenCanvas(IChartComponentFactory factory, Scene scene, Quality quality, GLProfile profile, int width, int height) {
|
||||
this(factory, scene, quality, profile, width, height, false, false);
|
||||
public OffscreenCanvas(IChartComponentFactory factory, Scene scene, Quality quality, GLCapabilities capabilities, int width, int height) {
|
||||
this(factory, scene, quality, capabilities, width, height, false, false);
|
||||
}
|
||||
|
||||
public OffscreenCanvas(IChartComponentFactory factory, Scene scene, Quality quality, GLProfile profile, int width, int height, boolean traceGL, boolean debugGL) {
|
||||
initGLPBuffer(width, height);
|
||||
public OffscreenCanvas(IChartComponentFactory factory, Scene scene, Quality quality, GLCapabilities capabilities, int width, int height, boolean traceGL, boolean debugGL) {
|
||||
view = scene.newView(this, quality);
|
||||
renderer = factory.newRenderer(view, traceGL, debugGL);
|
||||
initGLPBuffer(capabilities, width, height);
|
||||
}
|
||||
|
||||
protected void initGLPBuffer(GLCapabilities capabilities, int width, int height) {
|
||||
GLProfile profile = capabilities.getGLProfile();
|
||||
capabilities.setDoubleBuffered(false);
|
||||
if (!GLDrawableFactory.getFactory(profile).canCreateGLPbuffer(null))
|
||||
throw new RuntimeException("No pbuffer support");
|
||||
GLDrawableFactory factory = GLDrawableFactory.getFactory(profile);
|
||||
glpBuffer = factory.createGLPbuffer(null, capabilities, null, width, height, null);
|
||||
glpBuffer.addGLEventListener(renderer);
|
||||
}
|
||||
|
||||
// public OffscreenCanvas(IChartComponentFactory factory, Scene scene, Quality quality, GLProfile profile, int width, int height) {
|
||||
// view = scene.newView(this, quality);
|
||||
// renderer = factory.newRenderer(view, false, false);
|
||||
//
|
||||
// initGLPBuffer(width, height);
|
||||
// }
|
||||
|
||||
protected void initGLPBuffer(int width, int height) {
|
||||
GLCapabilities caps = org.jzy3d.global.Settings.getInstance().getGLCapabilities();
|
||||
caps.setDoubleBuffered(false);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.jzy3d.junit;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
|
@ -8,9 +8,9 @@ import java.io.IOException;
|
|||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import org.jzy3d.chart.Chart;
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ import org.jzy3d.chart.Chart;
|
|||
*
|
||||
* @author martin
|
||||
*/
|
||||
public class ChartTest extends TestCase{
|
||||
public class ChartTest{
|
||||
public static ChartTest tester = new ChartTest();
|
||||
|
||||
public static void assertSimilar(Chart chart, String testImage){
|
||||
|
@ -222,6 +222,11 @@ public class ChartTest extends TestCase{
|
|||
public String getTestCanvasType() {
|
||||
return "offscreen, " + WIDTH + ", " + HEIGHT;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void voidTest() {
|
||||
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
|
|
|
@ -12,13 +12,15 @@ import org.jzy3d.plot3d.builder.Mapper;
|
|||
import org.jzy3d.plot3d.builder.concrete.OrthonormalGrid;
|
||||
import org.jzy3d.plot3d.primitives.Shape;
|
||||
import org.jzy3d.plot3d.rendering.legends.colorbars.ColorbarLegend;
|
||||
import org.jzy3d.utils.LoggerUtils;
|
||||
|
||||
public class SimpleChartTest extends ChartTest{
|
||||
@Test()
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
// LoggerUtils.minimal();
|
||||
// Chart chart = chart(getTestCanvasType());
|
||||
// execute(chart);
|
||||
LoggerUtils.minimal();
|
||||
Chart chart = chart(getTestCanvasType());
|
||||
execute(chart);
|
||||
}
|
||||
|
||||
public static Chart chart(String wt){
|
||||
|
|
Loading…
Reference in New Issue