Passing directly the FloatBuffer to the GPU
Completed the keypad key assignments
This commit is contained in:
parent
872bc3f943
commit
d5b34941bd
@ -2,8 +2,8 @@ package org.warp.picalculator;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.KeyboardEventListener;
|
||||
import org.warp.picalculator.gui.expression.InputContext;
|
||||
import org.warp.picalculator.gui.expression.blocks.BlockContainer;
|
||||
@ -99,7 +99,7 @@ public class TestGPU {
|
||||
case RESET:
|
||||
c.clear();
|
||||
return true;
|
||||
case POWER:
|
||||
case POWEROFF:
|
||||
d.destroy();
|
||||
System.exit(0);
|
||||
return true;
|
||||
|
12
src/main/java/org/warp/picalculator/device/Key.java
Normal file
12
src/main/java/org/warp/picalculator/device/Key.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.warp.picalculator.device;
|
||||
|
||||
public enum Key {
|
||||
POWEROFF, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK,
|
||||
HISTORY_FORWARD, SURD_MODE, DRG_CYCLE, LETTER_X, LETTER_Y, LETTER_Z, STEP,
|
||||
SIMPLIFY, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2,
|
||||
NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE,
|
||||
PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT,
|
||||
UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2,
|
||||
POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI, SETTINGS,
|
||||
F1, F2, F3, F4, BACK
|
||||
}
|
@ -101,7 +101,7 @@ public class Keyboard {
|
||||
private synchronized static void debugKeyPressed(int keyCode) {
|
||||
switch (keyCode) {
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
Keyboard.keyPressed(Key.POWER);
|
||||
Keyboard.keyPressed(Key.POWEROFF);
|
||||
break;
|
||||
case KeyEvent.VK_S:
|
||||
if (Keyboard.shift) {
|
||||
@ -462,76 +462,76 @@ public class Keyboard {
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,5 */
|
||||
{Key.SETTINGS, Key.NONE, Key.NONE}, /* 0,5 */
|
||||
{Key.BRIGHTNESS_CYCLE, Key.BRIGHTNESS_CYCLE_REVERSE, Key.NONE}, /* 0,6 */
|
||||
{Key.SIMPLIFY, Key.STEP, Key.NONE} /* 0,7 */
|
||||
},
|
||||
{ /* ROW 1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,0 */
|
||||
{Key.F4, Key.F4, Key.F4}, /* 1,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 1,6 */
|
||||
{Key.LEFT, Key.NONE, Key.NONE}, /* 1,2 */
|
||||
{Key.OK, Key.NONE, Key.NONE}, /* 1,3 */
|
||||
{Key.RIGHT, Key.NONE, Key.NONE}, /* 1,4 */
|
||||
{Key.HISTORY_BACK, Key.NONE, Key.NONE}, /* 1,5 */
|
||||
{Key.HISTORY_FORWARD, Key.NONE, Key.NONE}, /* 1,6 */
|
||||
{Key.NONE, Key.PI, Key.DRG_CYCLE} /* 1,7 */
|
||||
},
|
||||
{ /* ROW 2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,0 */
|
||||
{Key.SQRT, Key.NONE, Key.LETTER_Y}, /* 2,1 */
|
||||
{Key.F3, Key.F4, Key.F4}, /* 2,0 */
|
||||
{Key.SQRT, Key.ROOT, Key.NONE}, /* 2,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,4 */
|
||||
{Key.DOWN, Key.NONE, Key.NONE}, /* 2,3 */
|
||||
{Key.BACK, Key.NONE, Key.NONE}, /* 2,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 2,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 2,7 */
|
||||
{Key.NONE, Key.NONE, Key.LETTER_Z} /* 2,7 */
|
||||
},
|
||||
{ /* ROW 3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,0 */
|
||||
{Key.F2, Key.F2, Key.F2}, /* 3,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,3 */
|
||||
{Key.POWER_OF_x, Key.NONE, Key.NONE}, /* 3,2 */
|
||||
{Key.POWER_OF_2, Key.NONE, Key.NONE}, /* 3,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 3,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 3,7 */
|
||||
{Key.DOT, Key.NONE, Key.LETTER_Y} /* 3,7 */
|
||||
},
|
||||
{ /* ROW 4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,0 */
|
||||
{Key.F1, Key.F1, Key.F1}, /* 4,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,3 */
|
||||
{Key.PARENTHESIS_OPEN, Key.NONE, Key.NONE}, /* 4,2 */
|
||||
{Key.PARENTHESIS_CLOSE, Key.NONE, Key.NONE}, /* 4,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,5 */
|
||||
{Key.SURD_MODE, Key.NONE, Key.NONE}, /* 4,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 4,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 4,7 */
|
||||
{Key.NUM0, Key.NONE, Key.LETTER_X} /* 4,7 */
|
||||
},
|
||||
{ /* ROW 5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,4 */
|
||||
{Key.NUM7, Key.NONE, Key.NONE}, /* 5,0 */
|
||||
{Key.NUM8, Key.NONE, Key.NONE}, /* 5,1 */
|
||||
{Key.NUM9, Key.NONE, Key.NONE}, /* 5,2 */
|
||||
{Key.DELETE, Key.NONE, Key.NONE}, /* 5,3 */
|
||||
{Key.RESET, Key.NONE, Key.NONE}, /* 5,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 5,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 5,7 */
|
||||
},
|
||||
{ /* ROW 6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,4 */
|
||||
{Key.NUM4, Key.NONE, Key.NONE}, /* 6,0 */
|
||||
{Key.NUM5, Key.NONE, Key.NONE}, /* 6,1 */
|
||||
{Key.NUM6, Key.NONE, Key.NONE}, /* 6,2 */
|
||||
{Key.MULTIPLY, Key.NONE, Key.NONE}, /* 6,3 */
|
||||
{Key.DIVIDE, Key.NONE, Key.NONE}, /* 6,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 6,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 6,7 */
|
||||
},
|
||||
{ /* ROW 7 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,0 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,1 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,2 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,3 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,4 */
|
||||
{Key.NUM1, Key.NONE, Key.NONE}, /* 7,0 */
|
||||
{Key.NUM2, Key.NONE, Key.NONE}, /* 7,1 */
|
||||
{Key.NUM3, Key.NONE, Key.NONE}, /* 7,2 */
|
||||
{Key.PLUS, Key.PLUS_MINUS, Key.NONE}, /* 7,3 */
|
||||
{Key.MINUS, Key.NONE, Key.NONE}, /* 7,4 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,5 */
|
||||
{Key.NONE, Key.NONE, Key.NONE}, /* 7,6 */
|
||||
{Key.NONE, Key.NONE, Key.NONE} /* 7,7 */
|
||||
@ -586,7 +586,7 @@ public class Keyboard {
|
||||
refresh = true;
|
||||
} else {
|
||||
switch (k) {
|
||||
case POWER:
|
||||
case POWEROFF:
|
||||
DisplayManager.INSTANCE.engine.destroy();
|
||||
break;
|
||||
case NONE:
|
||||
@ -678,10 +678,6 @@ public class Keyboard {
|
||||
additionalListener = l;
|
||||
}
|
||||
|
||||
public static enum Key {
|
||||
POWER, debug_DEG, debug_RAD, debug_GRA, SHIFT, ALPHA, NONE, HISTORY_BACK, HISTORY_FORWARD, SURD_MODE, DRG_CYCLE, LETTER_X, LETTER_Y, STEP, SIMPLIFY, BRIGHTNESS_CYCLE, BRIGHTNESS_CYCLE_REVERSE, DOT, NUM0, NUM1, NUM2, NUM3, NUM4, NUM5, NUM6, NUM7, NUM8, NUM9, PARENTHESIS_OPEN, PARENTHESIS_CLOSE, PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT, UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2, POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI
|
||||
}
|
||||
|
||||
public static boolean popRefreshRequest() {
|
||||
if (refreshRequest) {
|
||||
refreshRequest = false;
|
||||
@ -695,49 +691,79 @@ public class Keyboard {
|
||||
/*
|
||||
|
||||
|
||||
-coord-
|
||||
NORMAL
|
||||
SHIFT
|
||||
ALPHA
|
||||
-------
|
||||
|
||||
|0,0---|0,1---|------|0,3---|------|------|0,6---|
|
||||
|SHIFT |ALPHA |------| ^ |------|------|+BRIGH|
|
||||
|SHIFT |ALPHA |------| |------|------|-BRIGH|
|
||||
|SHIFT |ALPHA |------| |------|------| |
|
||||
|1,0---|1,1---|1,2---|1,3---|1,4---|1,5---|1,6---|
|
||||
| = | | < | OK | > | Back | Fwd |
|
||||
| | | | | | | |
|
||||
| | | | | | | |
|
||||
|2,0---|2,1---|------|2,3---|------|2,5---|2,6---|
|
||||
| | SQRT |------| v |------| | |
|
||||
| | ROOT |------| |------| | |
|
||||
| | |------| |------| | |
|
||||
|3,0---|3,1---|3,2---|3,3---|3,4---|3,5---|3,6---|
|
||||
| | | POW 2| POW x| | | |
|
||||
| | | | | | | |
|
||||
| | | | | | | |
|
||||
|4,0---|4,1---|4,2---|4,3---|4,4---|4,5---|4,6---|
|
||||
| | | | | |S<=>D | |
|
||||
| | | | | | | |
|
||||
| | | | | | | |
|
||||
|5,0---|5,1---|5,2---|5,3---|5,4---|5,5---|5,6---|
|
||||
| 7 | 8 | 9 | DEL | RESET |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|6,0---|6,1---|6,2---|6,3---|6,4-----------------|
|
||||
| 4 | 5 | 6 | * | / |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|7,0---|7,1---|7,2---|7,3---|7,4-----------------|
|
||||
| 1 | 2 | 3 | + | - |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|4,7---|3,7---|2,7---|1,7---|0,7-----------------|
|
||||
| 0 | . | | | SIMPLIFY |
|
||||
| | | |PI | STEP |
|
||||
| X | Y | Z |DRGCYCL|SOLVE FOR [x] |
|
||||
|------|------|------|------|--------------------|
|
||||
Keyboard:
|
||||
Example button:
|
||||
|ROW,COLUMN----|
|
||||
| NORMAL STATE |
|
||||
| SHIFT STATE |
|
||||
| ALPHA STATE |
|
||||
|--------------|
|
||||
|
||||
Physical keyboard:
|
||||
|0,0-----|0,1-----|########|0,3-----|########|0,5-----|0,6-----|
|
||||
| SHIFT | ALPHA |########| ^ |########|SETTINGS|+BRIGHT |
|
||||
| NORMAL | ALPHA |########| |########| |-BRIGHT |
|
||||
| SHIFT | NORMAL |########| |########| | |
|
||||
|1,0-----|1,1-----|1,2-----|1,3-----|1,4-----|1,5-----|1,6-----|
|
||||
| F_4 | | < | OK | > | Back | Fwd |
|
||||
| F_4 | | | | | | |
|
||||
| F_4 | | | | | | |
|
||||
|2,0-----|2,1-----|--------|2,3-----|--------|2,5-----|2,6-----|
|
||||
| F_3 | SQRT |########| v | BACK | | |
|
||||
| F_3 | ROOT |########| | | | |
|
||||
| F_3 | |########| | | | |
|
||||
|3,0-----|3,1-----|3,2-----|3,3-----|3,4-----|3,5-----|3,6-----|
|
||||
| F_2 | | POW x | POW 2 | | | |
|
||||
| F_2 | | | | | | |
|
||||
| F_2 | | | | | | |
|
||||
|4,0-----|4,1-----|4,2-----|4,3-----|4,4-----|4,5-----|4,6-----|
|
||||
| F_1 | | ( | ) | | S<=>D | |
|
||||
| F_1 | | | | | | |
|
||||
| F_1 | | | | | | |
|
||||
|5,0-----|5,1-----|5,2-----|5,3-----|5,4-----|5,5-----|5,6-----|
|
||||
| 7 | 8 | 9 | DEL | RESET |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|6,0-----|6,1-----|6,2-----|6,3-----|6,4-----------------------|
|
||||
| 4 | 5 | 6 | * | / |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|7,0-----|7,1-----|7,2-----|7,3-----|7,4-----------------------|
|
||||
| 1 | 2 | 3 | + | - |
|
||||
| | | | | |
|
||||
| | | | | |
|
||||
|4,7-----|3,7-----|2,7-----|1,7-----|0,7-----------------------|
|
||||
| 0 | . | | | SIMPLIFY |
|
||||
| | | |PI | STEP |
|
||||
| X | Y | Z |DRG CYCL| |
|
||||
|--------|--------|--------|--------|--------------------------|
|
||||
|
||||
SCREEN F_n:
|
||||
MathInputScreen:
|
||||
Default:
|
||||
[F_1] Normal: Solve for X Shift: Solve for _ Alpha:
|
||||
[F_2] Normal: Shift: Alpha:
|
||||
[F_3] Normal: Variables & constants Shift: Alpha:
|
||||
[F_4] Normal: Functions f(x) Shift: Alpha:
|
||||
Variable popup:
|
||||
[F_1] Normal(if constant):Set value Shift: Alpha:
|
||||
[F_2] Normal: Shift: Alpha:
|
||||
[F_3] Normal: Shift: Alpha:
|
||||
[F_4] Normal: Shift: Alpha:
|
||||
MarioScreen
|
||||
[F_1] Normal: Shift: Alpha:
|
||||
[F_2] Normal: Shift: Alpha:
|
||||
[F_3] Normal: Shift: Alpha:
|
||||
[F_4] Normal: Shift: Alpha:
|
||||
ChooseVariableValueScreen
|
||||
[F_1] Normal: Shift: Alpha:
|
||||
[F_2] Normal: Shift: Alpha:
|
||||
[F_3] Normal: Shift: Alpha:
|
||||
[F_4] Normal: Shift: Alpha:
|
||||
SolveForXScreen
|
||||
[F_1] Normal: Shift: Alpha:
|
||||
[F_2] Normal: Shift: Alpha:
|
||||
[F_3] Normal: Shift: Alpha:
|
||||
[F_4] Normal: Shift: Alpha:
|
||||
*/
|
@ -1,7 +1,5 @@
|
||||
package org.warp.picalculator.device;
|
||||
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
|
||||
public interface KeyboardEventListener {
|
||||
public abstract boolean keyPressed(Key k);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.warp.picalculator.gui.expression.blocks;
|
||||
|
||||
import org.warp.picalculator.Error;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.expression.Caret;
|
||||
import org.warp.picalculator.gui.expression.ExtraMenu;
|
||||
|
@ -25,7 +25,7 @@ public class CPUFont implements BinaryFont {
|
||||
public int charH;
|
||||
public int charS;
|
||||
public int charIntCount;
|
||||
public LinkedList<Integer[]> intervals;
|
||||
public int[] intervals;
|
||||
public int intervalsTotalSize = 0;
|
||||
public static final int intBits = 31;
|
||||
private final boolean isResource;
|
||||
@ -167,7 +167,7 @@ public class CPUFont implements BinaryFont {
|
||||
}
|
||||
|
||||
private void findIntervals() {
|
||||
intervals = new LinkedList<Integer[]>();
|
||||
final LinkedList<int[]> intervals = new LinkedList<int[]>();
|
||||
int beginIndex = -1;
|
||||
int endIndex = 0;
|
||||
int intervalSize = 0;
|
||||
@ -183,7 +183,7 @@ public class CPUFont implements BinaryFont {
|
||||
i = endIndex;
|
||||
if (endIndex >= 0) {
|
||||
intervalSize = endIndex - beginIndex + 1;
|
||||
intervals.add(new Integer[] {beginIndex, endIndex, intervalSize});
|
||||
intervals.add(new int[] {beginIndex, endIndex, intervalSize});
|
||||
intervalsTotalSize += intervalSize;
|
||||
}
|
||||
beginIndex = -1;
|
||||
@ -191,7 +191,7 @@ public class CPUFont implements BinaryFont {
|
||||
}
|
||||
int lastIndex = 0;
|
||||
boolean[][] newrawchars = new boolean[intervalsTotalSize][];
|
||||
for (Integer[] interval: intervals) {
|
||||
for (int[] interval: intervals) {
|
||||
if (rawchars.length - (interval[0]) - interval[2] < 0) {
|
||||
System.err.println(interval[0] + "-" + interval[1] + "(" + interval[2] + ")");
|
||||
System.err.println(rawchars.length - (interval[0]) - interval[2]);
|
||||
@ -205,6 +205,14 @@ public class CPUFont implements BinaryFont {
|
||||
lastIndex += interval[2];
|
||||
}
|
||||
rawchars = newrawchars;
|
||||
final int intervalsSize = intervals.size();
|
||||
this.intervals = new int[intervalsSize * 3];
|
||||
for (int i = 0; i < intervalsSize; i++) {
|
||||
int[] interval = intervals.get(i);
|
||||
this.intervals[i * 3 + 0] = interval[0];
|
||||
this.intervals[i * 3 + 1] = interval[1];
|
||||
this.intervals[i * 3 + 2] = interval[2];
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -237,14 +245,14 @@ public class CPUFont implements BinaryFont {
|
||||
|
||||
private int compressIndex(int originalIndex) {
|
||||
int compressedIndex = 0;
|
||||
for (Integer[] interval : intervals) {
|
||||
if (interval[0] > originalIndex) {
|
||||
for (int i = 0; i < intervals.length; i+=3) {
|
||||
if (intervals[i] > originalIndex) {
|
||||
break;
|
||||
} else if (originalIndex <= interval[1]) {
|
||||
compressedIndex+=(originalIndex-interval[0]);
|
||||
} else if (originalIndex <= intervals[i+1]) {
|
||||
compressedIndex+=(originalIndex-intervals[i]);
|
||||
break;
|
||||
} else {
|
||||
compressedIndex+=interval[2];
|
||||
compressedIndex+=intervals[i+2];
|
||||
}
|
||||
}
|
||||
return compressedIndex;
|
||||
@ -253,12 +261,12 @@ public class CPUFont implements BinaryFont {
|
||||
private int decompressIndex(int compressedIndex) {
|
||||
int originalIndex = 0;
|
||||
int i = 0;
|
||||
for (Integer[] interval : intervals) {
|
||||
i+=interval[2];
|
||||
for (int intvl = 0; intvl < intervals.length; intvl+=3) {
|
||||
i+=intervals[intvl+2];
|
||||
if (i == compressedIndex) {
|
||||
return interval[1];
|
||||
return intervals[intvl+1];
|
||||
} else if (i > compressedIndex) {
|
||||
return interval[1] - (i - compressedIndex);
|
||||
return intervals[intvl+1] - (i - compressedIndex);
|
||||
}
|
||||
}
|
||||
return originalIndex;
|
||||
|
@ -28,7 +28,7 @@ public class GPUFont implements BinaryFont {
|
||||
public int charH;
|
||||
public int minCharIndex;
|
||||
public int maxCharIndex;
|
||||
public LinkedList<Integer[]> intervals;
|
||||
public int[] intervals;
|
||||
public int intervalsTotalSize = 0;
|
||||
public int memoryWidth;
|
||||
public int memoryHeight;
|
||||
@ -89,14 +89,14 @@ public class GPUFont implements BinaryFont {
|
||||
|
||||
private int compressIndex(int originalIndex) {
|
||||
int compressedIndex = 0;
|
||||
for (Integer[] interval : intervals) {
|
||||
if (interval[0] > originalIndex) {
|
||||
for (int i = 0; i < intervals.length; i+=3) {
|
||||
if (intervals[i] > originalIndex) {
|
||||
break;
|
||||
} else if (originalIndex <= interval[1]) {
|
||||
compressedIndex+=(originalIndex-interval[0]);
|
||||
} else if (originalIndex <= intervals[i+1]) {
|
||||
compressedIndex+=(originalIndex-intervals[i]);
|
||||
break;
|
||||
} else {
|
||||
compressedIndex+=interval[2];
|
||||
compressedIndex+=intervals[i+2];
|
||||
}
|
||||
}
|
||||
return compressedIndex;
|
||||
@ -105,10 +105,10 @@ public class GPUFont implements BinaryFont {
|
||||
private int decompressIndex(int compressedIndex) {
|
||||
int originalIndex = 0;
|
||||
int i = 0;
|
||||
for (Integer[] interval : intervals) {
|
||||
i+=interval[2];
|
||||
for (int intvl = 0; i < intervals.length; i+=3) {
|
||||
i+=intervals[intvl+2];
|
||||
if (i >= compressedIndex) {
|
||||
return interval[1] - (i - compressedIndex);
|
||||
return intervals[intvl+1] - (i - compressedIndex);
|
||||
}
|
||||
}
|
||||
return originalIndex;
|
||||
|
@ -27,12 +27,15 @@ public class GPURenderer implements Renderer {
|
||||
|
||||
public static GL2ES1 gl;
|
||||
|
||||
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
|
||||
private static final int ELEMENT_VERTICES_COUNT = 6,
|
||||
vertSize = 3, texSize = 2, colSize = 4,
|
||||
vertBuffer = 0, texBuffer = 1, colBuffer = 2;
|
||||
private static final int ELEMENTS_MAX_COUNT_PER_BUFFER = StaticVars.enableVBO ? 128 : 1;
|
||||
vertBuffer = 0, texBuffer = 1, colBuffer = 2,
|
||||
vertMax = vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER,
|
||||
texMax = texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER,
|
||||
colMax = colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER;
|
||||
|
||||
private IntBuffer handlers;
|
||||
private int[] handlers;
|
||||
private final DeallocationHelper deallocationHelper = new DeallocationHelper();
|
||||
FloatBuffer fbVertices;
|
||||
FloatBuffer fbTextures;
|
||||
@ -299,11 +302,11 @@ public class GPURenderer implements Renderer {
|
||||
public void initDrawCycle() {
|
||||
final boolean textureChange = precTexEnabled != currentTexEnabled || precTex != currentTex;
|
||||
if (fbVertices == null) {
|
||||
fbVertices = Buffers.newDirectFloatBuffer(vertSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||
fbTextures = Buffers.newDirectFloatBuffer(texSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||
fbColors = Buffers.newDirectFloatBuffer(colSize * ELEMENT_VERTICES_COUNT * ELEMENTS_MAX_COUNT_PER_BUFFER);
|
||||
handlers = Buffers.newDirectIntBuffer(3);
|
||||
gl.glGenBuffers(3, handlers);
|
||||
fbVertices = Buffers.newDirectFloatBuffer(vertMax);
|
||||
fbTextures = Buffers.newDirectFloatBuffer(texMax);
|
||||
fbColors = Buffers.newDirectFloatBuffer(colMax);
|
||||
handlers = new int[3];
|
||||
gl.glGenBuffers(3, handlers, 0);
|
||||
}
|
||||
startDrawSegment(false);
|
||||
if (textureChange) {
|
||||
@ -374,7 +377,7 @@ public class GPURenderer implements Renderer {
|
||||
fbColors.flip();
|
||||
|
||||
// gl.glVertexPointer(vertSize, GL.GL_FLOAT, 0, fbVertices);
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers.get(vertBuffer));
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers[vertBuffer]);
|
||||
if (firstBufferTexDataCall) {
|
||||
gl.glBufferData(
|
||||
GL.GL_ARRAY_BUFFER, fbVertices.limit() * Buffers.SIZEOF_FLOAT,
|
||||
@ -387,7 +390,7 @@ public class GPURenderer implements Renderer {
|
||||
}
|
||||
gl.glVertexPointer(vertSize, GL.GL_FLOAT, 0, 0l);
|
||||
// gl.glTexCoordPointer(texSize, GL.GL_FLOAT, 0, fbTextures);
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers.get(texBuffer));
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers[texBuffer]);
|
||||
if (firstBufferTexDataCall) {
|
||||
gl.glBufferData(
|
||||
GL.GL_ARRAY_BUFFER, fbTextures.limit() * Buffers.SIZEOF_FLOAT,
|
||||
@ -400,7 +403,7 @@ public class GPURenderer implements Renderer {
|
||||
}
|
||||
gl.glTexCoordPointer(texSize, GL.GL_FLOAT, 0, 0l);
|
||||
// gl.glColorPointer(colSize, GL.GL_FLOAT, 0, fbColors);
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers.get(colBuffer));
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, handlers[colBuffer]);
|
||||
if (firstBufferTexDataCall) {
|
||||
gl.glBufferData(
|
||||
GL.GL_ARRAY_BUFFER, fbColors.limit() * Buffers.SIZEOF_FLOAT,
|
||||
@ -412,11 +415,10 @@ public class GPURenderer implements Renderer {
|
||||
fbColors);
|
||||
}
|
||||
gl.glColorPointer(colSize, GL.GL_FLOAT, 0, 0l);
|
||||
gl.glBindBuffer(GL.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
fbVertices.limit(fbVertices.capacity());
|
||||
fbTextures.limit(fbTextures.capacity());
|
||||
fbColors.limit(fbColors.capacity());
|
||||
fbVertices.limit(vertMax);
|
||||
fbTextures.limit(texMax);
|
||||
fbColors.limit(colMax);
|
||||
gl.glDrawArrays(GL.GL_TRIANGLES, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
||||
//gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, 0, fbElements * ELEMENT_VERTICES_COUNT);
|
||||
firstBufferDataCall = false;
|
||||
|
@ -29,8 +29,8 @@
|
||||
package org.warp.picalculator.gui.graphicengine.gpu;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
|
||||
import com.jogamp.newt.event.KeyEvent;
|
||||
@ -142,7 +142,7 @@ class NEWTWindow implements GLEventListener {
|
||||
public void keyReleased(KeyEvent arg0) {
|
||||
switch (arg0.getKeyCode()) {
|
||||
case KeyEvent.VK_ESCAPE:
|
||||
Keyboard.keyReleased(Key.POWER);
|
||||
Keyboard.keyReleased(Key.POWEROFF);
|
||||
break;
|
||||
case KeyEvent.VK_D:
|
||||
Keyboard.keyReleased(Key.debug_DEG);
|
||||
|
@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
|
||||
import org.fusesource.jansi.internal.WindowsSupport;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
||||
|
||||
|
@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
|
||||
import org.fusesource.jansi.internal.WindowsSupport;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
||||
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitRenderer;
|
||||
|
@ -7,8 +7,8 @@ import org.fusesource.jansi.AnsiConsole;
|
||||
import org.fusesource.jansi.internal.WindowsSupport;
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
import org.warp.picalculator.gui.graphicengine.RenderingLoop;
|
||||
import org.warp.picalculator.gui.graphicengine.headless24bit.Headless24bitRenderer;
|
||||
|
@ -2,7 +2,7 @@ package org.warp.picalculator.gui.screens;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.Utils;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.math.Function;
|
||||
import org.warp.picalculator.math.functions.Variable.VariableValue;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.warp.picalculator.gui.screens;
|
||||
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
|
||||
public class EmptyScreen extends Screen {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.warp.picalculator.gui.screens;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.graphicengine.Renderer;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.warp.picalculator.gui.screens;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.GraphicUtils;
|
||||
|
||||
|
@ -3,8 +3,8 @@ package org.warp.picalculator.gui.screens;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.graphicengine.BinaryFont;
|
||||
import org.warp.picalculator.gui.graphicengine.Skin;
|
||||
|
@ -7,8 +7,8 @@ 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.Key;
|
||||
import org.warp.picalculator.device.Keyboard;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
import org.warp.picalculator.gui.expression.InputContext;
|
||||
import org.warp.picalculator.gui.expression.blocks.Block;
|
||||
|
@ -1,15 +1,15 @@
|
||||
package org.warp.picalculator.gui.screens;
|
||||
|
||||
import org.warp.picalculator.StaticVars;
|
||||
import org.warp.picalculator.device.Keyboard.Key;
|
||||
import org.warp.picalculator.device.Key;
|
||||
import org.warp.picalculator.gui.DisplayManager;
|
||||
|
||||
public class SolveEquationScreen extends Screen {
|
||||
public class SolveForXScreen extends Screen {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final MathInputScreen es;
|
||||
|
||||
public SolveEquationScreen(MathInputScreen es) {
|
||||
public SolveForXScreen(MathInputScreen es) {
|
||||
super();
|
||||
canBeInHistory = false;
|
||||
|
Loading…
Reference in New Issue
Block a user