From 6e17aa46607fd18480baa0c019426672085d093d Mon Sep 17 00:00:00 2001 From: Andrea Cavalli Date: Mon, 1 May 2017 22:39:00 +0200 Subject: [PATCH] Updated the headless engine --- .../warp/picalculator/gui/DisplayManager.java | 1 + .../gui/graphicengine/cpu/CPUEngine.java | 1 + .../gui/graphicengine/gpu/GPUEngine.java | 1 + .../headless/HeadlessEngine.java | 111 +++++++++++++++ .../graphicengine/headless/HeadlessFont.java | 42 ++++++ .../headless/HeadlessRenderer.java | 130 ++++++++++++++++++ .../graphicengine/headless/HeadlessSkin.java | 28 ++++ 7 files changed, 314 insertions(+) create mode 100644 src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessFont.java create mode 100644 src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessSkin.java diff --git a/src/main/java/org/warp/picalculator/gui/DisplayManager.java b/src/main/java/org/warp/picalculator/gui/DisplayManager.java index 1faeed82..c26acd27 100755 --- a/src/main/java/org/warp/picalculator/gui/DisplayManager.java +++ b/src/main/java/org/warp/picalculator/gui/DisplayManager.java @@ -87,6 +87,7 @@ public final class DisplayManager implements RenderingLoop { d = new HeadlessEngine(); if (d.isSupported()) { System.err.println("Using Headless Engine! This is a problem! No other graphic engines are available."); + return d; } throw new UnsupportedOperationException("No graphic engines available."); } diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/cpu/CPUEngine.java b/src/main/java/org/warp/picalculator/gui/graphicengine/cpu/CPUEngine.java index 2aa2c979..9d7e10a1 100755 --- a/src/main/java/org/warp/picalculator/gui/graphicengine/cpu/CPUEngine.java +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/cpu/CPUEngine.java @@ -471,6 +471,7 @@ public class CPUEngine implements GraphicEngine { @Override public boolean isSupported() { + if (true) return false; return GraphicsEnvironment.isHeadless() == false; } 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 7da0b9fe..39883cdb 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,6 +125,7 @@ public class GPUEngine implements org.warp.picalculator.gui.graphicengine.Graphi @Override public boolean isSupported() { + if (true) return false; boolean available = false; boolean errored = false; try { 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 index ddf7e6fd..264134c3 100755 --- a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessEngine.java @@ -1,4 +1,115 @@ package org.warp.picalculator.gui.graphicengine.headless; +import java.io.IOException; + +import org.warp.picalculator.gui.graphicengine.Renderer; +import org.warp.picalculator.gui.graphicengine.RenderingLoop; +import org.warp.picalculator.gui.graphicengine.Skin; + public class HeadlessEngine implements org.warp.picalculator.gui.graphicengine.GraphicEngine { + + private HeadlessRenderer r = new HeadlessRenderer(); + private boolean stopped; + + @Override + public int[] getSize() { + return new int[]{480, 320}; + } + + @Override + public boolean isInitialized() { + return true; + } + + @Override + public void setTitle(String title) { + // TODO Auto-generated method stub + + } + + @Override + public void setResizable(boolean r) { + // TODO Auto-generated method stub + + } + + @Override + public void setDisplayMode(int ww, int wh) { + // TODO Auto-generated method stub + + } + + @Override + public void create() { + // TODO Auto-generated method stub + + } + + @Override + public boolean wasResized() { + return false; + } + + @Override + public int getWidth() { + return 480; + } + + @Override + public int getHeight() { + return 320; + } + + @Override + public void destroy() { + stopped = true; + } + + @Override + public void start(RenderingLoop d) { + // TODO Auto-generated method stub + + } + + @Override + public void repaint() { + // TODO Auto-generated method stub + + } + + @Override + public Renderer getRenderer() { + return r; + } + + @Override + public HeadlessFont loadFont(String file) throws IOException { + return new HeadlessFont(); + } + + @Override + public HeadlessSkin loadSkin(String file) throws IOException { + return new HeadlessSkin(); + } + + @Override + public void waitUntilExit() { + try { + do { + Thread.sleep(500); + } while (stopped==false); + } catch (final InterruptedException e) { + + } + } + + @Override + public boolean isSupported() { + return true; + } + + @Override + public boolean doesRefreshPauses() { + return false; + } } diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessFont.java b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessFont.java new file mode 100644 index 00000000..845448ea --- /dev/null +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessFont.java @@ -0,0 +1,42 @@ +package org.warp.picalculator.gui.graphicengine.headless; + +import java.io.IOException; + +import org.warp.picalculator.gui.graphicengine.BinaryFont; +import org.warp.picalculator.gui.graphicengine.GraphicEngine; + +public class HeadlessFont implements BinaryFont { + + @Override + public void load(String file) throws IOException { + + } + + @Override + public void initialize(GraphicEngine d) { + // TODO Auto-generated method stub + + } + + @Override + public void use(GraphicEngine d) { + // TODO Auto-generated method stub + + } + + @Override + public int getStringWidth(String text) { + return 5*text.length(); + } + + @Override + public int getCharacterWidth() { + return 5; + } + + @Override + public int getCharacterHeight() { + return 5; + } + +} 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 index f386b974..dc692970 100755 --- a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessRenderer.java @@ -1,5 +1,135 @@ package org.warp.picalculator.gui.graphicengine.headless; +import org.warp.picalculator.gui.graphicengine.Renderer; + public class HeadlessRenderer implements Renderer { + + HeadlessFont currentFont; + + @Override + public void glColor3i(int r, int gg, int b) { + // TODO Auto-generated method stub + + } + + @Override + public void glColor(int c) { + // TODO Auto-generated method stub + + } + + @Override + public void glColor4i(int red, int green, int blue, int alpha) { + // TODO Auto-generated method stub + + } + + @Override + public void glColor3f(float red, float green, float blue) { + // TODO Auto-generated method stub + + } + + @Override + public void glColor4f(float red, float green, float blue, float alpha) { + // TODO Auto-generated method stub + + } + + @Override + public void glClearColor4i(int red, int green, int blue, int alpha) { + // TODO Auto-generated method stub + + } + + @Override + public void glClearColor4f(float red, float green, float blue, float alpha) { + // TODO Auto-generated method stub + + } + + @Override + public int glGetClearColor() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public void glClearColor(int c) { + // TODO Auto-generated method stub + + } + + @Override + public void glClear(int screenWidth, int screenHeight) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawLine(float x0, float y0, float x1, float y1) { + // TODO Auto-generated method stub + + } + + @Override + public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth, + float uvHeight) { + // TODO Auto-generated method stub + + } + + @Override + public void glFillColor(float x, float y, float width, float height) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawCharLeft(int x, int y, char ch) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawCharCenter(int x, int y, char ch) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawCharRight(int x, int y, char ch) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawStringLeft(float x, float y, String text) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawStringCenter(float x, float y, String text) { + // TODO Auto-generated method stub + + } + + @Override + public void glDrawStringRight(float x, float y, String text) { + // TODO Auto-generated method stub + + } + + @Override + public void glClearSkin() { + // TODO Auto-generated method stub + + } + + @Override + public HeadlessFont getCurrentFont() { + return currentFont; + } } diff --git a/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessSkin.java b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessSkin.java new file mode 100644 index 00000000..16294cdf --- /dev/null +++ b/src/main/java/org/warp/picalculator/gui/graphicengine/headless/HeadlessSkin.java @@ -0,0 +1,28 @@ +package org.warp.picalculator.gui.graphicengine.headless; + +import java.io.IOException; + +import org.warp.picalculator.gui.graphicengine.GraphicEngine; +import org.warp.picalculator.gui.graphicengine.Skin; + +public class HeadlessSkin implements Skin { + + @Override + public void load(String file) throws IOException { + // TODO Auto-generated method stub + + } + + @Override + public void initialize(GraphicEngine d) { + // TODO Auto-generated method stub + + } + + @Override + public void use(GraphicEngine d) { + // TODO Auto-generated method stub + + } + +}