Updated the headless engine

This commit is contained in:
Andrea Cavalli 2017-05-01 22:39:00 +02:00
parent 144fb1593f
commit 6e17aa4660
7 changed files with 314 additions and 0 deletions

View File

@ -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.");
}

View File

@ -471,6 +471,7 @@ public class CPUEngine implements GraphicEngine {
@Override
public boolean isSupported() {
if (true) return false;
return GraphicsEnvironment.isHeadless() == false;
}

View File

@ -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 {

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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
}
}