Improved VBO support and bugfixes.

This commit is contained in:
Andrea Cavalli 2017-10-17 22:49:21 +02:00
parent 3ef698b28b
commit 574f1adb60
23 changed files with 170 additions and 139 deletions

View File

@ -1,6 +1,7 @@
package org.warp.picalculator;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.screens.LoadingScreen;
import org.warp.picalculator.gui.screens.Screen;
@ -9,16 +10,8 @@ import com.pi4j.system.SystemInfo.BoardType;
import com.pi4j.wiringpi.Gpio;
public class Main {
public static int[] screenPos = new int[] { 0, 0 };
public static final int[] screenSize = new int[] { 480, 320 };
public static final boolean zoomed = true;
public static Main instance;
public static boolean haxMode = true;
public static String[] args;
public static final String calculatorName = "WarpPI";
public static final String calculatorNameLOWER = "warppi";
public static final String calculatorNameUPPER = "WARPPI";
public Main(String[] args) throws InterruptedException {
this(new LoadingScreen(), args);
}
@ -48,10 +41,10 @@ public class Main {
Gpio.wiringPiSetupPhys();
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
} else {
screenPos = new int[] { 0, 0 };
Utils.debugOn = true;
StaticVars.screenPos = new int[] { 0, 0 };
StaticVars.debugOn = true;
}
Utils.debugThirdScreen = Utils.debugOn & false;
Utils.debugThirdScreen = StaticVars.debugOn & false;
for (String arg : args) {
if (arg.contains("headless")) {
Utils.headlessOverride = true;

View File

@ -0,0 +1,19 @@
package org.warp.picalculator;
public class StaticVars {
public static final boolean enableVBO = true;
public static final String calculatorName = "WarpPI";
public static final String calculatorNameLOWER = "warppi";
public static final String calculatorNameUPPER = "WARPPI";
public static boolean haxMode = true;
public static final boolean zoomed = true;
public static int[] screenPos = new int[] { 0, 0 };
public static final int[] screenSize = new int[] { 480, 320 };
public static boolean debugOn;
public static int outputLevel = 5;
public static final boolean debugWindow2x = true;
private StaticVars() {
}
}

View File

@ -24,7 +24,7 @@ public class TestGPU {
public static final GraphicEngine d = new GPUEngine();
public static void main(String[] args) throws IOException, Error {
Utils.debugOn = true;
StaticVars.debugOn = true;
Utils.debugThirdScreen = false;
d.create();
@ -178,7 +178,7 @@ public class TestGPU {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (!Utils.debugOn) {
if (!StaticVars.debugOn) {
d.destroy();
System.exit(0);
}

View File

@ -48,13 +48,10 @@ public class Utils {
public static AdvancedOutputStream out = new AdvancedOutputStream();
public static boolean debugOn;
public static int outputLevel = 5;
public static final int OUTPUTLEVEL_NODEBUG = 0;
public static final int OUTPUTLEVEL_DEBUG_MIN = 1;
public static final int OUTPUTLEVEL_DEBUG_MAX = 4;
public static boolean debugThirdScreen;
public static final boolean debugWindow2x = true;
public static boolean headlessOverride = false;
private static String OS = System.getProperty("os.name").toLowerCase();
public static String forceEngine;
@ -67,8 +64,8 @@ public class Utils {
}
public void println(int level) {
if (outputLevel >= level) {
if (outputLevel == 0) {
if (StaticVars.outputLevel >= level) {
if (StaticVars.outputLevel == 0) {
System.out.println();
} else {
System.err.println();
@ -77,8 +74,8 @@ public class Utils {
}
public void println(int level, String str) {
if (outputLevel >= level) {
if (outputLevel == 0) {
if (StaticVars.outputLevel >= level) {
if (StaticVars.outputLevel == 0) {
System.out.println(str);
} else {
System.err.println(str);
@ -87,8 +84,8 @@ public class Utils {
}
public void print(int level, String str) {
if (outputLevel >= level) {
if (outputLevel == 0) {
if (StaticVars.outputLevel >= level) {
if (StaticVars.outputLevel == 0) {
System.out.print(str);
} else {
System.err.print(str);
@ -464,7 +461,7 @@ public class Utils {
}
public static final BinaryFont getFont(boolean small) {
return getFont(small, Main.zoomed);
return getFont(small, StaticVars.zoomed);
}
public static final BinaryFont getFont(boolean small, boolean zoomed) {
@ -488,7 +485,7 @@ public class Utils {
}
public static final int getFontHeight(boolean small) {
return getFontHeight(small, Main.zoomed);
return getFontHeight(small, StaticVars.zoomed);
}
public static final int getFontHeight(boolean small, boolean zoomed) {

View File

@ -9,7 +9,7 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.UUID;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
public class CacheFile {
private String path;
@ -23,7 +23,7 @@ public class CacheFile {
path = UUID.randomUUID().toString() + ".ser";
} while (Files.exists(Paths.get(path)));
try {
Files.createTempFile(Main.calculatorNameLOWER, "");
Files.createTempFile(StaticVars.calculatorNameLOWER, "");
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -2,6 +2,7 @@ package org.warp.picalculator.device;
import java.awt.event.KeyEvent;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.chip.ParallelToSerial;
import org.warp.picalculator.device.chip.SerialToParallel;
@ -36,7 +37,7 @@ public class Keyboard {
public synchronized static void startKeyboard() {
final Thread kt = new Thread(() -> {
if (Utils.debugOn) {
if (StaticVars.debugOn) {
try {
while (true) {
if (debugKeyCode != -1) {
@ -238,7 +239,7 @@ public class Keyboard {
if (!Keyboard.shift && !Keyboard.alpha) {
Keyboard.keyPressed(Key.NUM7);
} else if (Keyboard.shift) {
if (Utils.debugOn) {
if (StaticVars.debugOn) {
Keyboard.keyPressed(Key.DIVIDE);
}
}
@ -428,7 +429,7 @@ public class Keyboard {
}
public static boolean isKeyDown(int row, int col) {
if (Utils.debugOn == false) {
if (StaticVars.debugOn == false) {
return precedentStates[row - 1][col - 1];
} else {
return debugKeysDown[row - 1][col - 1];
@ -746,7 +747,7 @@ public class Keyboard {
}
public static void stopKeyboard() {
if (Utils.debugOn == false) {
if (StaticVars.debugOn == false) {
Gpio.digitalWrite(33, false);
Gpio.digitalWrite(35, false);
Gpio.digitalWrite(36, false);
@ -819,7 +820,7 @@ public class Keyboard {
default:
break;
}
if (Utils.debugOn == false) {
if (StaticVars.debugOn == false) {
if (k != Key.SHIFT && Keyboard.shift) {
Keyboard.shift = false;
refresh = true;

View File

@ -4,7 +4,7 @@ import java.io.IOException;
import java.util.List;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
@ -242,7 +242,7 @@ public final class DisplayManager implements RenderingLoop {
fonts[2] = engine.loadFont("ex");
fonts[3] = engine.loadFont("big");
//4
fonts[5] = engine.loadFont("square");
//fonts[5] = engine.loadFont("square");
}
private void draw_init() {
@ -297,7 +297,7 @@ public final class DisplayManager implements RenderingLoop {
final int brightness = (int) (Math.ceil(DisplayManager.INSTANCE.brightness * 9));
if (brightness <= 10) {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * brightness, 16 * 1, 16, 16);
} else {
Utils.out.println(1, "Brightness error");
}
@ -307,19 +307,19 @@ public final class DisplayManager implements RenderingLoop {
final boolean canGoBack = canGoBack();
final boolean canGoForward = canGoForward();
if (Main.haxMode) {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
if (StaticVars.haxMode) {
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 18, 16 * 0, 16, 16);
padding += 18 + 6;
}
if (canGoBack && canGoForward) {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 14, 16 * 0, 16, 16);
} else if (canGoBack) {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 15, 16 * 0, 16, 16);
} else if (canGoForward) {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 16, 16 * 0, 16, 16);
} else {
renderer.glFillRect(Main.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
renderer.glFillRect(StaticVars.screenSize[0] - (padding + 16), 2, 16, 16, 16 * 17, 16 * 0, 16, 16);
}
padding += 18;
@ -336,13 +336,13 @@ public final class DisplayManager implements RenderingLoop {
Utils.getFont(true, false).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 40);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, Main.screenSize[1] - 7 - 7 + 1, "WORK IN");
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 - 7 + 1, "WORK IN");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 80);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, Main.screenSize[1] - 7 - 7, "WORK IN");
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7 - 7, "WORK IN");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 40);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, Main.screenSize[1] - 7 + 1, "PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1 + 1, StaticVars.screenSize[1] - 7 + 1, "PROGRESS.");
DisplayManager.INSTANCE.renderer.glColor4i(255, 0, 0, 80);
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, Main.screenSize[1] - 7, "PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringLeft(1, StaticVars.screenSize[1] - 7, "PROGRESS.");
}
private void draw_world() {
@ -352,9 +352,9 @@ public final class DisplayManager implements RenderingLoop {
BinaryFont fnt = Utils.getFont(false, false);
fnt.use(engine);
renderer.glColor3i(129, 28, 22);
renderer.glDrawStringRight(Main.screenSize[0] - 2, Main.screenSize[1] - (fnt.getCharacterHeight() + 2), Main.calculatorNameUPPER + " CALCULATOR");
renderer.glDrawStringRight(StaticVars.screenSize[0] - 2, StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2), StaticVars.calculatorNameUPPER + " CALCULATOR");
renderer.glColor3i(149, 32, 26);
renderer.glDrawStringCenter((Main.screenSize[0] / 2), 22, error);
renderer.glDrawStringCenter((StaticVars.screenSize[0] / 2), 22, error);
renderer.glColor3i(164, 34, 28);
int i = 22;
for (final String stackPart : errorStackTrace) {
@ -363,7 +363,7 @@ public final class DisplayManager implements RenderingLoop {
}
fonts[0].use(engine);
renderer.glColor3i(129, 28, 22);
renderer.glDrawStringCenter((Main.screenSize[0] / 2), 11, "UNEXPECTED EXCEPTION");
renderer.glDrawStringCenter((StaticVars.screenSize[0] / 2), 11, "UNEXPECTED EXCEPTION");
} else {
fonts[0].use(engine);
draw_screen();
@ -389,8 +389,8 @@ public final class DisplayManager implements RenderingLoop {
private void checkDisplayResized() {
if (engine.wasResized()) {
Main.screenSize[0] = engine.getWidth();
Main.screenSize[1] = engine.getHeight();
StaticVars.screenSize[0] = engine.getWidth();
StaticVars.screenSize[1] = engine.getHeight();
}
};
@ -500,7 +500,7 @@ public final class DisplayManager implements RenderingLoop {
public void setBrightness(float newval) {
if (newval >= 0 && newval <= 1) {
brightness = newval;
if (Utils.debugOn == false) {
if (StaticVars.debugOn == false) {
Gpio.pwmWrite(12, (int) Math.ceil(brightness * 1024f));
// SoftPwm.softPwmWrite(12, (int)(Math.ceil(brightness*10)));
} else {

View File

@ -5,7 +5,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
@ -51,8 +51,8 @@ public class CPUEngine implements GraphicEngine {
@Override
public void create(Runnable onInitialized) {
INSTANCE = new SwingWindow(this);
setResizable(Utils.debugOn & !Utils.debugThirdScreen);
setDisplayMode(Main.screenSize[0], Main.screenSize[1]);
setResizable(StaticVars.debugOn & !Utils.debugThirdScreen);
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
INSTANCE.setVisible(true);
initialized = true;
if (onInitialized != null)
@ -73,12 +73,12 @@ public class CPUEngine implements GraphicEngine {
@Override
public int getWidth() {
return INSTANCE.getWidth() - Main.screenPos[0];
return INSTANCE.getWidth() - StaticVars.screenPos[0];
}
@Override
public int getHeight() {
return INSTANCE.getHeight() - Main.screenPos[1];
return INSTANCE.getHeight() - StaticVars.screenPos[1];
}
@Override

View File

@ -2,7 +2,7 @@ package org.warp.picalculator.gui.graphicengine.cpu;
import java.awt.FontMetrics;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -54,8 +54,8 @@ public class CPURenderer implements Renderer {
}
private void glDrawSkin(int x0, int y0, int s0, int t0, int s1, int t1, boolean transparent) {
x0 += Main.screenPos[0];
y0 += Main.screenPos[1];
x0 += StaticVars.screenPos[0];
y0 += StaticVars.screenPos[1];
int oldColor;
int newColor;
final int onex = s0 <= s1 ? 1 : -1;
@ -126,10 +126,10 @@ public class CPURenderer implements Renderer {
@Override
public void glDrawLine(float x0, float y0, float x1, float y1) {
x0 += Main.screenPos[0];
x1 += Main.screenPos[0];
y0 += Main.screenPos[1];
y1 += Main.screenPos[1];
x0 += StaticVars.screenPos[0];
x1 += StaticVars.screenPos[0];
y0 += StaticVars.screenPos[1];
y1 += StaticVars.screenPos[1];
final int ix0 = (int) x0;
final int ix1 = (int) x1;
final int iy0 = (int) y0;
@ -173,8 +173,8 @@ public class CPURenderer implements Renderer {
@Override
public void glFillColor(float x, float y, float width, float height) {
x += Main.screenPos[0];
y += Main.screenPos[1];
x += StaticVars.screenPos[0];
y += StaticVars.screenPos[1];
final int ix = (int) x;
final int iy = (int) y;
@ -210,8 +210,8 @@ public class CPURenderer implements Renderer {
@Override
public void glDrawStringLeft(float x, float y, String textString) {
x += Main.screenPos[0];
y += Main.screenPos[1];
x += StaticVars.screenPos[0];
y += StaticVars.screenPos[1];
final int ix = (int) x;
final int iy = (int) y;

View File

@ -15,6 +15,7 @@ import java.awt.image.DataBufferInt;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
@ -27,6 +28,7 @@ public class SwingWindow extends JFrame {
private RenderingLoop renderingLoop;
public boolean wasResized = false;
private final CPUEngine display;
private int mult = 1;
public SwingWindow(CPUEngine disp) {
display = disp;
@ -38,7 +40,8 @@ public class SwingWindow extends JFrame {
// Transparent 16 x 16 pixel cursor image.
final BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
if (Utils.debugOn) {
if (StaticVars.debugOn) {
if (StaticVars.debugWindow2x) mult = 3;
if (Utils.debugThirdScreen) {
this.setLocation(2880, 900);
setResizable(false);
@ -202,24 +205,24 @@ public class SwingWindow extends JFrame {
@Override
public void setSize(int width, int height) {
c.setSize(width, height);
super.getContentPane().setPreferredSize(new Dimension(width, height));
c.setSize(width*mult, height*mult);
super.getContentPane().setPreferredSize(new Dimension(width*mult, height*mult));
super.pack();
}
@Override
public Dimension getSize() {
return c.getSize();
return new Dimension(getWidth(), getHeight());
}
@Override
public int getWidth() {
return c.getWidth();
return c.getWidth()/mult;
}
@Override
public int getHeight() {
return c.getHeight();
return c.getHeight()/mult;
}
public void setRenderingLoop(RenderingLoop renderingLoop) {
@ -244,8 +247,8 @@ public class SwingWindow extends JFrame {
final int[] a = ((DataBufferInt) display.g.getRaster().getDataBuffer()).getData();
// System.arraycopy(canvas2d, 0, a, 0, canvas2d.length);
CPURenderer.canvas2d = a;
g.clearRect(0, 0, display.r.size[0], display.r.size[1]);
g.drawImage(display.g, 0, 0, null);
g.clearRect(0, 0, display.r.size[0]*mult, display.r.size[1]*mult);
g.drawImage(display.g, 0, 0, display.r.size[0]*mult, display.r.size[1]*mult, null);
// long time2 = System.nanoTime();
// double timeDelta = ((double)(time2-time1))/1000000000d;
// double mediaAttuale = timeDelta;

View File

@ -1,10 +1,15 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.Semaphore;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.GraphicEngine;
@ -20,7 +25,8 @@ public class GPUEngine implements GraphicEngine {
private NEWTWindow wnd;
private RenderingLoop d;
private GPURenderer r;
int[] size = new int[] { Main.screenSize[0], Main.screenSize[1] };
private Map<String, GPUFont> fontCache = new HashMap<String, GPUFont>();
int[] size = new int[] { StaticVars.screenSize[0], StaticVars.screenSize[1] };
private final CopyOnWriteArrayList<BinaryFont> registeredFonts = new CopyOnWriteArrayList<BinaryFont>();
private Semaphore exitSemaphore = new Semaphore(0);
@ -53,7 +59,7 @@ public class GPUEngine implements GraphicEngine {
public void setDisplayMode(int ww, int wh) {
size[0] = ww;
size[1] = wh;
wnd.window.setSize((Utils.debugOn & Utils.debugWindow2x) ? ww * 2 : ww, (Utils.debugOn & Utils.debugWindow2x) ? wh * 2 : wh);
wnd.window.setSize((StaticVars.debugOn & StaticVars.debugWindow2x) ? ww * 2 : ww, (StaticVars.debugOn & StaticVars.debugWindow2x) ? wh * 2 : wh);
}
@Override
@ -67,15 +73,15 @@ public class GPUEngine implements GraphicEngine {
r = new GPURenderer();
wnd = new NEWTWindow(this);
wnd.create();
setDisplayMode(Main.screenSize[0], Main.screenSize[1]);
setResizable(Utils.debugOn & !Utils.debugThirdScreen);
setDisplayMode(StaticVars.screenSize[0], StaticVars.screenSize[1]);
setResizable(StaticVars.debugOn & !Utils.debugThirdScreen);
initialized = true;
wnd.onInitialized = onInitialized;
}
@Override
public boolean wasResized() {
return Main.screenSize[0] != size[0] | Main.screenSize[1] != size[1];
return StaticVars.screenSize[0] != size[0] | StaticVars.screenSize[1] != size[1];
}
@Override
@ -116,7 +122,14 @@ public class GPUEngine implements GraphicEngine {
@Override
public BinaryFont loadFont(String file) throws IOException {
return new GPUFont(this, file);
for (Entry<String, GPUFont> entry : fontCache.entrySet()) {
if (entry.getKey().equals(file)) {
return entry.getValue();
}
}
GPUFont font = new GPUFont(this, file);
fontCache.put(file, font);
return font;
}
@Override
@ -140,7 +153,7 @@ public class GPUEngine implements GraphicEngine {
boolean available = false;
boolean errored = false;
try {
available = GLProfile.isAvailable(GLProfile.GL2ES1);
available = GLProfile.isAvailable(GLProfile.GL2ES2);
} catch (Exception ex) {
errored = true;
System.err.println(ex.getMessage());

View File

@ -11,6 +11,7 @@ import java.nio.FloatBuffer;
import javax.imageio.ImageIO;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.gui.graphicengine.BinaryFont;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -27,7 +28,7 @@ public class GPURenderer implements Renderer {
public static GL2ES1 gl;
private static final int ELEMENT_VERTICES_COUNT = 6;
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = 128;
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
private final DeallocationHelper deallocationHelper = new DeallocationHelper();
FloatBuffer fbVertices;

View File

@ -28,7 +28,7 @@
package org.warp.picalculator.gui.graphicengine.gpu;
import org.warp.picalculator.Utils;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
@ -76,7 +76,9 @@ class NEWTWindow implements GLEventListener {
System.err.println("Le OpenGL non sono presenti su questo computer!");
return;
}
System.setProperty("jnlp.newt.window.icons", "res/icons/calculator-016.png res/icons/calculator-018.png res/icons/calculator-256.png");
if (StaticVars.debugOn) {
System.setProperty("jnlp.newt.window.icons", "res/icons/calculator-016.png res/icons/calculator-018.png res/icons/calculator-256.png");
}
final GLCapabilities caps = new GLCapabilities(GLProfile.get(GLProfile.GL2ES1));
System.out.println("Loaded OpenGL");
// We may at this point tweak the caps and request a translucent drawable
@ -311,8 +313,8 @@ class NEWTWindow implements GLEventListener {
@Override
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
disp.size[0] = (Utils.debugOn & Utils.debugWindow2x) ? width / 2 : width;
disp.size[1] = (Utils.debugOn & Utils.debugWindow2x) ? height / 2 : height;
disp.size[0] = (StaticVars.debugOn & StaticVars.debugWindow2x) ? width / 2 : width;
disp.size[1] = (StaticVars.debugOn & StaticVars.debugWindow2x) ? height / 2 : height;
final GL2ES1 gl = glad.getGL().getGL2ES1();
if (width == 0) {
width = 1;
@ -326,7 +328,7 @@ class NEWTWindow implements GLEventListener {
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
gl.glLoadIdentity();
gl.glOrtho(0.0, (Utils.debugOn & Utils.debugWindow2x) ? width / 2 : width, (Utils.debugOn & Utils.debugWindow2x) ? height / 2 : height, 0.0, -1, 1);
gl.glOrtho(0.0, (StaticVars.debugOn & StaticVars.debugWindow2x) ? width / 2 : width, (StaticVars.debugOn & StaticVars.debugWindow2x) ? height / 2 : height, 0.0, -1, 1);
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
gl.glLoadIdentity();
@ -337,11 +339,11 @@ class NEWTWindow implements GLEventListener {
final GL2ES1 gl = glad.getGL().getGL2ES1();
GPURenderer.gl = gl;
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
renderer.updateDrawCycle(true, false);
disp.repaint();

View File

@ -5,7 +5,7 @@ import java.util.logging.ConsoleHandler;
import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
@ -19,9 +19,9 @@ public class Headless24bitEngine implements org.warp.picalculator.gui.graphiceng
private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8;
public static final int C_MUL_Y = 8;//8;
protected static final int C_WIDTH = Main.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = Main.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = Main.calculatorName;
protected static final int C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = StaticVars.calculatorName;
private boolean win = false;
private Key precKey = null;
@ -62,7 +62,7 @@ public class Headless24bitEngine implements org.warp.picalculator.gui.graphiceng
@Override
public void create(Runnable onInitialized) {
Utils.outputLevel = -1;
StaticVars.outputLevel = -1;
AnsiConsole.systemInstall();
if (Utils.isWindows() && !Utils.msDosMode) {
win = true;

View File

@ -5,7 +5,7 @@ import java.util.logging.ConsoleHandler;
import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
@ -20,9 +20,9 @@ public class Headless256Engine implements org.warp.picalculator.gui.graphicengin
private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8;
public static final int C_MUL_Y = 8;//8;
protected static final int C_WIDTH = Main.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = Main.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = Main.calculatorName;
protected static final int C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = StaticVars.calculatorName;
private boolean win = false;
private Key precKey = null;
@ -61,7 +61,7 @@ public class Headless256Engine implements org.warp.picalculator.gui.graphicengin
@Override
public void create(Runnable onInitialized) {
Utils.outputLevel = -1;
StaticVars.outputLevel = -1;
AnsiConsole.systemInstall();
if (Utils.isWindows() && !Utils.msDosMode) {
win = true;

View File

@ -5,7 +5,7 @@ import java.util.logging.ConsoleHandler;
import org.fusesource.jansi.AnsiConsole;
import org.fusesource.jansi.internal.WindowsSupport;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
@ -20,9 +20,9 @@ public class Headless8Engine implements org.warp.picalculator.gui.graphicengine.
private RenderingLoop renderLoop;
public static final int C_MUL_X = 4;//8;
public static final int C_MUL_Y = 8;//8;
protected static final int C_WIDTH = Main.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = Main.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = Main.calculatorName;
protected static final int C_WIDTH = StaticVars.screenSize[0] / C_MUL_X;//Main.screenSize[0]/2;//;60;
protected static final int C_HEIGHT = StaticVars.screenSize[1] / C_MUL_Y;//Main.screenSize[1]/3;//;40;
private String title = StaticVars.calculatorName;
private boolean win = false;
private Key precKey = null;
@ -61,7 +61,7 @@ public class Headless8Engine implements org.warp.picalculator.gui.graphicengine.
@Override
public void create(Runnable onInitialized) {
Utils.outputLevel = -1;
StaticVars.outputLevel = -1;
AnsiConsole.systemInstall();
if (Utils.isWindows() && !Utils.msDosMode) {
win = true;

View File

@ -1,6 +1,6 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
@ -30,19 +30,19 @@ public class ChooseVariableValueScreen extends Screen {
public void render() {
Utils.getFont(false, true).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 - 20 + 1, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 - 20, "WORK IN PROGRESS.");
Utils.getFont(false, false).use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 2 + 1, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 2, "THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override

View File

@ -1,6 +1,6 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.graphicengine.Renderer;
@ -30,7 +30,7 @@ public class KeyboardDebugScreen extends Screen {
final Renderer renderer = DisplayManager.INSTANCE.renderer;
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
renderer.glColor4f(0.75f, 0.0f, 0.0f, 1.0f);
renderer.glDrawStringRight(Main.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
renderer.glDrawStringRight(StaticVars.screenSize[0] - 10, 30, "-" + keyevent.toUpperCase() + "-");
if (keyevent != "NONE") {
DisplayManager.INSTANCE.fonts[2].use(DisplayManager.INSTANCE.engine);
renderer.glColor4f(0.0f, 0.0f, 0.0f, 1.0f);

View File

@ -1,6 +1,6 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
import org.warp.picalculator.gui.GraphicUtils;
@ -39,11 +39,11 @@ public class LoadingScreen extends Screen {
public void render() {
DisplayManager.INSTANCE.guiSkin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor3i(255, 255, 255);
DisplayManager.INSTANCE.renderer.glFillRect(Main.screenSize[0] / 2f - 80, Main.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
DisplayManager.INSTANCE.renderer.glFillRect(Main.screenSize[0] / 2f - 24, Main.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] / 2f - 80, StaticVars.screenSize[1] / 2f - 64, 160, 48, 0, 32, 160, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] / 2f - 24, StaticVars.screenSize[1] / 2f - loadingTextTranslation, 48, 48, 160, 32, 48, 48);
DisplayManager.INSTANCE.renderer.glFillRect(Main.screenSize[0] - 224, Main.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
DisplayManager.INSTANCE.renderer.glFillRect(Main.screenSize[0] - 160 - 24 - 224, Main.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] - 224, StaticVars.screenSize[1] - 48, 224, 48, 0, 80, 224, 48);
DisplayManager.INSTANCE.renderer.glFillRect(StaticVars.screenSize[0] - 160 - 24 - 224, StaticVars.screenSize[1] - 48, 160, 48, 224, 80, 160, 48);
}

View File

@ -2,7 +2,7 @@ package org.warp.picalculator.gui.screens;
import java.io.IOException;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
@ -162,23 +162,23 @@ public class MarioScreen extends Screen {
if (easterfont != null) {
easterfont.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glColor(0xFF000000);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "A");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "A");
DisplayManager.INSTANCE.renderer.glColor(0xFF800000);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "B");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "B");
DisplayManager.INSTANCE.renderer.glColor(0xFFeea28e);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "C");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "C");
DisplayManager.INSTANCE.renderer.glColor(0xFFee7255);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "D");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "D");
DisplayManager.INSTANCE.renderer.glColor(0xFFeac0b0);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "E");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "E");
DisplayManager.INSTANCE.renderer.glColor(0xFFf3d8ce);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "F");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "F");
DisplayManager.INSTANCE.renderer.glColor(0xFFffede7);
DisplayManager.INSTANCE.renderer.glDrawStringRight(Main.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "G");
DisplayManager.INSTANCE.renderer.glDrawStringRight(StaticVars.screenSize[0], DisplayManager.INSTANCE.engine.getHeight() - easterfont.getCharacterHeight(), "G");
}
if (easterskin != null) {
easterskin.use(DisplayManager.INSTANCE.engine);
DisplayManager.INSTANCE.renderer.glFillRect(0, Main.screenSize[1] - 128, 224, 128, easterNum * 224, 0, 224, 128);
DisplayManager.INSTANCE.renderer.glFillRect(0, StaticVars.screenSize[1] - 128, 224, 128, easterNum * 224, 0, 224, 128);
easterNum = (easterNum < easterMax) ? easterNum + 1 : 0;
}

View File

@ -7,6 +7,7 @@ import java.util.List;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.Keyboard.Key;
@ -243,7 +244,7 @@ public class MathInputScreen extends Screen {
// });
}
} catch (final Exception ex) {
if (Utils.debugOn) {
if (StaticVars.debugOn) {
ex.printStackTrace();
}
throw new Error(Errors.SYNTAX_ERROR);

View File

@ -1,6 +1,6 @@
package org.warp.picalculator.gui.screens;
import org.warp.picalculator.Main;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.device.Keyboard.Key;
import org.warp.picalculator.gui.DisplayManager;
@ -25,11 +25,11 @@ public class SolveEquationScreen extends Screen {
@Override
public void render() {
DisplayManager.INSTANCE.renderer.glColor4i(0, 0, 0, 64);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2 + 1, Main.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2 + 1, StaticVars.screenSize[1] / 4 + 1, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glColor3i(255, 0, 0);
DisplayManager.INSTANCE.renderer.glDrawStringCenter(Main.screenSize[0] / 2, Main.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
DisplayManager.INSTANCE.renderer.glDrawStringCenter(StaticVars.screenSize[0] / 2, StaticVars.screenSize[1] / 4, "WORK IN PROGRESS. THIS SCREEN MUST HAVE A GUI TO SELECT THE VARIABLE TO SOLVE.");
}
@Override

View File

@ -3,6 +3,7 @@ package org.warp.picalculator.math.parser;
import org.warp.picalculator.Error;
import org.warp.picalculator.Errors;
import org.warp.picalculator.IntegerObj;
import org.warp.picalculator.StaticVars;
import org.warp.picalculator.Utils;
import org.warp.picalculator.gui.expression.blocks.Block;
import org.warp.picalculator.gui.expression.containers.InputContainer;
@ -80,7 +81,7 @@ public class MathParser {
boolean lastLoopDidSomething;
Function lastElement;
if (Utils.debugOn) {
if (StaticVars.debugOn) {
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MAX, "\tStatus: ");
for (Function f : functionsList) {
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MAX, f.toString());
@ -89,7 +90,7 @@ public class MathParser {
}
for (MathParserStep step : steps) {
if (Utils.debugOn) {
if (StaticVars.debugOn) {
Utils.out.println(2, "Stack fixing step \"" + step.getStepName() + "\"");
}
int stepQty = step.requiresReversedIteration() ? -1 : 1,
@ -111,7 +112,7 @@ public class MathParser {
}
} while (lastLoopDidSomething);
if (Utils.debugOn) {
if (StaticVars.debugOn) {
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MAX, "\tStatus: ");
for (Function f : functionsList) {
Utils.out.print(Utils.OUTPUTLEVEL_DEBUG_MAX, f.toString());