Added "NoGUI" Engine

This commit is contained in:
Andrea Cavalli 2018-03-21 15:18:44 +01:00
parent ef948579a4
commit c58bc6c9e0
3 changed files with 290 additions and 0 deletions

View File

@ -80,6 +80,9 @@ public class Main {
if (arg.contains("fb")) {
Utils.forceEngine = "fb";
}
if (arg.contains("nogui")) {
Utils.forceEngine = "nogui";
}
if (arg.contains("verbose") || arg.contains("debug")) {
StaticVars.outputLevel = Utils.OUTPUTLEVEL_DEBUG_VERBOSE;
}

View File

@ -18,6 +18,7 @@ import org.warp.picalculator.gui.graphicengine.gpu.GPUEngine;
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitEngine;
import org.warp.picalculator.gui.graphicengine.headless256.Headless256Engine;
import org.warp.picalculator.gui.graphicengine.headless8.Headless8Engine;
import org.warp.picalculator.gui.graphicengine.nogui.NoGuiEngine;
import org.warp.picalculator.gui.screens.Screen;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
@ -108,6 +109,11 @@ public final class DisplayManager implements RenderingLoop {
private GraphicEngine chooseGraphicEngine() {
GraphicEngine d;
d = new NoGuiEngine();
if (d.isSupported()) {
Utils.out.println(1, "Using NoGui Graphic Engine");
return d;
}
if (!StaticVars.debugOn) {
d = new FBEngine();
if (d.isSupported()) {

View File

@ -0,0 +1,281 @@
package org.warp.picalculator.gui.graphicengine.nogui;
import java.awt.GraphicsEnvironment;
import java.io.IOException;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
import org.warp.picalculator.gui.graphicengine.Renderer;
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
import org.warp.picalculator.gui.graphicengine.Skin;
public class NoGuiEngine implements GraphicEngine {
private boolean initialized;
public Semaphore exitSemaphore = new Semaphore(0);
@Override
public int[] getSize() {
return new int[] {2, 2};
}
@Override
public boolean isInitialized() {
return initialized;
}
@Override
public void setTitle(String title) {
}
@Override
public void setResizable(boolean r) {
}
@Override
public void setDisplayMode(int ww, int wh) {
}
@Override
public void create(Runnable onInitialized) {
initialized = true;
if (onInitialized != null)
onInitialized.run();
}
@Override
public boolean wasResized() {
return false;
}
@Override
public int getWidth() {
return 2;
}
@Override
public int getHeight() {
return 2;
}
@Override
public void destroy() {
initialized = false;
exitSemaphore.release();
}
@Override
public void start(RenderingLoop d) {
}
@Override
public void repaint() {
}
@Override
public Renderer getRenderer() {
return new Renderer() {
@Override
public int glGetClearColor() {
return 0;
}
@Override
public void glFillRect(float x, float y, float width, float height, float uvX, float uvY, float uvWidth,
float uvHeight) {
}
@Override
public void glFillColor(float x, float y, float width, float height) {
}
@Override
public void glDrawStringRight(float x, float y, String text) {
}
@Override
public void glDrawStringLeft(float x, float y, String text) {
}
@Override
public void glDrawStringCenter(float x, float y, String text) {
}
@Override
public void glDrawLine(float x0, float y0, float x1, float y1) {
}
@Override
public void glDrawCharRight(int x, int y, char ch) {
}
@Override
public void glDrawCharLeft(int x, int y, char ch) {
}
@Override
public void glDrawCharCenter(int x, int y, char ch) {
}
@Override
public void glColor4i(int red, int green, int blue, int alpha) {
}
@Override
public void glColor4f(float red, float green, float blue, float alpha) {
}
@Override
public void glColor3i(int r, int gg, int b) {
}
@Override
public void glColor3f(float red, float green, float blue) {
}
@Override
public void glColor(int c) {
}
@Override
public void glClearSkin() {
}
@Override
public void glClearColor4i(int red, int green, int blue, int alpha) {
}
@Override
public void glClearColor4f(float red, float green, float blue, float alpha) {
}
@Override
public void glClearColor(int c) {
}
@Override
public void glClear(int screenWidth, int screenHeight) {
}
@Override
public BinaryFont getCurrentFont() {
return null;
}
};
}
@Override
public BinaryFont loadFont(String fontName) throws IOException {
return new BinaryFont() {
@Override
public void use(GraphicEngine d) {
}
@Override
public void load(String file) throws IOException {
}
@Override
public boolean isInitialized() {
return true;
}
@Override
public void initialize(GraphicEngine d) {
}
@Override
public int getStringWidth(String text) {
return 1;
}
@Override
public int getCharacterWidth() {
return 1;
}
@Override
public int getCharacterHeight() {
return 1;
}
};
}
@Override
public BinaryFont loadFont(String path, String fontName) throws IOException {
return new BinaryFont() {
@Override
public void use(GraphicEngine d) {
}
@Override
public void load(String file) throws IOException {
}
@Override
public boolean isInitialized() {
return true;
}
@Override
public void initialize(GraphicEngine d) {
}
@Override
public int getStringWidth(String text) {
return 1;
}
@Override
public int getCharacterWidth() {
return 1;
}
@Override
public int getCharacterHeight() {
return 1;
}
};
}
@Override
public Skin loadSkin(String file) throws IOException {
return new Skin() {
@Override
public void use(GraphicEngine d) {
}
@Override
public void load(String file) throws IOException {
}
@Override
public boolean isInitialized() {
return true;
}
@Override
public void initialize(GraphicEngine d) {
}
};
}
@Override
public void waitForExit() {
try {
exitSemaphore.acquire();
} catch (InterruptedException e) {}
}
@Override
public boolean isSupported() {
return Utils.forceEngine != null && Utils.forceEngine.equals("nogui");
}
@Override
public boolean doesRefreshPauses() {
return true;
}
}