Updated some graphic libraries

This commit is contained in:
Andrea Cavalli 2018-03-29 00:30:47 +02:00
parent 4e9f4350f0
commit 575e9f4871
11 changed files with 79 additions and 42 deletions

1
.gitignore vendored
View File

@ -12,6 +12,7 @@
font_easter.png
font_easter.rft
font_fu32.rft
VBO_Example.java
/target/
!/target/*.jar

BIN
libs/raspi2fb Normal file

Binary file not shown.

View File

@ -1,5 +1,12 @@
package org.warp.picalculator;
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.warp.picalculator.device.Keyboard;
import org.warp.picalculator.device.PIHardwareDisplay;
import org.warp.picalculator.gui.CalculatorHUD;
@ -47,6 +54,11 @@ public class Main {
if (Utils.isRunningOnRaspberry() && !Utils.isInArray("-noraspi", args) && isRaspi) {
Gpio.wiringPiSetupPhys();
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
try {
Files.createFile(Paths.get("/boot/warppi_loaded"));
} catch (IOException e) {
e.printStackTrace();
}
} else {
StaticVars.screenPos = new int[] { 0, 0 };
StaticVars.debugOn = true;

View File

@ -76,6 +76,7 @@ public class Utils {
public static String forceEngine;
public static boolean msDosMode;
public static boolean debugCache;
public static boolean newtMode = true;
public static final class AdvancedOutputStream extends StringWriter {

View File

@ -303,7 +303,9 @@ public final class DisplayManager implements RenderingLoop {
if (error != null) {
BinaryFont fnt = Utils.getFont(false, false);
fnt.use(engine);
if (fnt != null && fnt != engine.getRenderer().getCurrentFont()) {
fnt.use(engine);
}
renderer.glColor3i(129, 28, 22);
renderer.glDrawStringRight(StaticVars.screenSize[0] - 2, StaticVars.screenSize[1] - (fnt.getCharacterHeight() + 2), StaticVars.calculatorNameUPPER + " CALCULATOR");
renderer.glColor3i(149, 32, 26);
@ -314,11 +316,15 @@ public final class DisplayManager implements RenderingLoop {
renderer.glDrawStringLeft(2, 22 + i, stackPart);
i += 11;
}
fonts[0].use(engine);
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
fonts[0].use(engine);
}
renderer.glColor3i(129, 28, 22);
renderer.glDrawStringCenter((StaticVars.screenSize[0] / 2), 11, "UNEXPECTED EXCEPTION");
} else {
fonts[0].use(engine);
if (fonts[0] != null && fonts[0] != engine.getRenderer().getCurrentFont()) {
fonts[0].use(engine);
}
hud.renderBackground();
screen.render();
hud.render();

View File

@ -143,7 +143,7 @@ public class FBEngine implements GraphicEngine {
realFb.getBuffer().clear();
realFb.getBuffer().put(fb);
for (int i = 0; i < fb.capacity()/2; i++) {
realFb.getBuffer().put(i, (byte) (0xFF));
realFb.getBuffer().put(i, (byte) (_________________TMP < 50 ? 0xFF : 0xF0));
}
for (int i = fb.capacity()/2; i < fb.capacity(); i++) {
realFb.getBuffer().put(i, (byte) (0x18));
@ -184,6 +184,7 @@ public class FBEngine implements GraphicEngine {
if (Utils.headlessOverride) {
return false;
}
/*
File fbFile = new File("/dev/fb1");
try {
fbFileRW = new RandomAccessFile(fbFile, "rw");
@ -194,6 +195,7 @@ public class FBEngine implements GraphicEngine {
System.err.println("Cannot read framebuffer fb1.");
ex.printStackTrace();
}
*/
return false;
}

View File

@ -193,4 +193,4 @@ public class GPUEngine implements GraphicEngine {
return registeredFonts;
}
}
}

View File

@ -292,13 +292,46 @@ public class GPURenderer implements Renderer {
return tex;
}
public void startDrawCycle(boolean first) {
public void initDrawCycle() {
final boolean textureChange = precTexEnabled != currentTexEnabled || precTex != currentTex;
startDrawSegment(false);
if (textureChange) {
changeTexture();
}
if (fbVertices == null) {
fbVertices = Buffers.newDirectFloatBuffer(3 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
txVertices = Buffers.newDirectFloatBuffer(2 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
colVertices = Buffers.newDirectFloatBuffer(4 * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
}
if (first || fbVertices == null || cycleEnded) {
}
public void endDrawCycle() {
final boolean textureChange = precTexEnabled != currentTexEnabled || precTex != currentTex;
if (textureChange) {
if (fbElements > 0) {
endDrawSegment();
}
changeTexture();
} else {
if (fbElements > 0) {
endDrawSegment();
}
}
}
private void changeTexture() {
precTexEnabled = currentTexEnabled;
precTex = currentTex;
if (currentTexEnabled) {
gl.glEnable(GL.GL_TEXTURE_2D);
currentTex.bind(gl);
} else {
gl.glDisable(GL.GL_TEXTURE_2D);
}
}
public void startDrawSegment(boolean continuation) {
if (!continuation || cycleEnded) {
fbElements = 0;
}
cycleEnded = false;
@ -308,42 +341,24 @@ public class GPURenderer implements Renderer {
private Texture precTex;
private boolean cycleEnded = true;
public void updateDrawCycle() {
updateDrawCycle(false, false);
}
public void updateDrawCycle(boolean first, boolean last) {
public void doDrawSegment() {
final boolean textureChange = precTexEnabled != currentTexEnabled || precTex != currentTex;
final boolean changeRequired = last || fbElements >= ELEMENTS_MAX_COUNT_PER_BUFFER;
if (first) {
startDrawCycle(true);
}
final boolean changeRequired = fbElements >= ELEMENTS_MAX_COUNT_PER_BUFFER;
if (textureChange) {
if (!first && fbElements > 0) {
endDrawCycle();
if (!last) {
startDrawCycle(true);
}
if (fbElements > 0) {
endDrawSegment();
startDrawSegment(false);
}
precTexEnabled = currentTexEnabled;
precTex = currentTex;
if (currentTexEnabled) {
gl.glEnable(GL.GL_TEXTURE_2D);
currentTex.bind(gl);
} else {
gl.glDisable(GL.GL_TEXTURE_2D);
}
} else if (!first) {
changeTexture();
} else {
if (fbElements > 0 && changeRequired) {
endDrawCycle();
if (!last) {
startDrawCycle(false);
}
endDrawSegment();
startDrawSegment(true);
}
}
}
public void endDrawCycle() {
public void endDrawSegment() {
fbVertices.limit(fbVertices.position());
txVertices.limit(txVertices.position());
colVertices.limit(colVertices.position());
@ -380,18 +395,18 @@ public class GPURenderer implements Renderer {
public void glClearSkin() {
if (currentTex != null) {
currentTex = null;
updateDrawCycle();
doDrawSegment();
}
}
void disableTexture() {
currentTexEnabled = false;
updateDrawCycle();
doDrawSegment();
}
void enableTexture() {
currentTexEnabled = true;
updateDrawCycle();
doDrawSegment();
}
void useTexture(Texture t, float w, float h) {
@ -400,4 +415,4 @@ public class GPURenderer implements Renderer {
currentTexHeight = h;
enableTexture();
}
}
}

View File

@ -343,12 +343,12 @@ class NEWTWindow implements GLEventListener {
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
renderer.updateDrawCycle(true, false);
renderer.initDrawCycle();
disp.repaint();
renderer.updateDrawCycle(false, true);
renderer.endDrawCycle();
GPURenderer.gl = null;

BIN
src/main/jni/libpicalc.so Normal file

Binary file not shown.

Binary file not shown.