From 144fb1593fd033458150ce84bd39061dbeac5406 Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Mon, 1 May 2017 20:30:39 +0000 Subject: [PATCH] added a headless render stub --- .../org/warp/picalculator/gui/DisplayManager.java | 10 ++++++++-- .../picalculator/gui/graphicengine/gpu/GPUEngine.java | 11 +++++++++-- .../gui/graphicengine/headless/HeadlessEngine.java | 4 ++++ .../gui/graphicengine/headless/HeadlessRenderer.java | 5 +++++ 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100755 src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java create mode 100755 src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java diff --git a/src/main/java/org/warp/picalculator/gui/DisplayManager.java b/src/main/java/org/warp/picalculator/gui/DisplayManager.java index a141e1d8..1faeed82 100755 --- a/src/main/java/org/warp/picalculator/gui/DisplayManager.java +++ b/src/main/java/org/warp/picalculator/gui/DisplayManager.java @@ -1,8 +1,9 @@ package org.warp.picalculator.gui; import java.io.IOException; + import it.unimi.dsi.fastutil.objects.ObjectArrayList; - + import org.warp.picalculator.Main; import org.warp.picalculator.Utils; import org.warp.picalculator.device.Keyboard; @@ -11,10 +12,11 @@ import org.warp.picalculator.gui.graphicengine.RenderingLoop; import org.warp.picalculator.gui.graphicengine.Renderer; import org.warp.picalculator.gui.graphicengine.cpu.CPUEngine; import org.warp.picalculator.gui.graphicengine.gpu.GPUEngine; +import org.warp.picalculator.gui.graphicengine.headless.HeadlessEngine; import org.warp.picalculator.gui.graphicengine.BinaryFont; import org.warp.picalculator.gui.graphicengine.Skin; import org.warp.picalculator.gui.screens.Screen; - + import com.pi4j.wiringpi.Gpio; public final class DisplayManager implements RenderingLoop { @@ -82,6 +84,10 @@ public final class DisplayManager implements RenderingLoop { Utils.debug.println("Using CPU Graphic Engine"); return d; } + d = new HeadlessEngine(); + if (d.isSupported()) { + System.err.println("Using Headless Engine! This is a problem! No other graphic engines are available."); + } throw new UnsupportedOperationException("No graphic engines available."); } diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPUEngine.java b/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPUEngine.java index c5a551e8..7da0b9fe 100755 --- a/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPUEngine.java +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/gpu/GPUEngine.java @@ -125,8 +125,15 @@ public class GPUEngine implements org.warp.picalculator.gui.graphicengine.Graphi @Override public boolean isSupported() { - final boolean available = GLProfile.isAvailable(GLProfile.GL2ES1); - if (!available) { + boolean available = false; + boolean errored = false; + try { + available = GLProfile.isAvailable(GLProfile.GL2ES1); + } catch (Exception ex) { + errored = true; + System.err.println(ex.getMessage()); + } + if (!available && !errored) { System.err.println(GLProfile.glAvailabilityToString()); } return available; diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java new file mode 100755 index 00000000..ddf7e6fd --- /dev/null +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java @@ -0,0 +1,4 @@ +package org.warp.picalculator.gui.graphicengine.headless; + +public class HeadlessEngine implements org.warp.picalculator.gui.graphicengine.GraphicEngine { +} diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java new file mode 100755 index 00000000..f386b974 --- /dev/null +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java @@ -0,0 +1,5 @@ +package org.warp.picalculator.gui.graphicengine.headless; + +public class HeadlessRenderer implements Renderer { + +}