2x zoom
This commit is contained in:
parent
d5b34941bd
commit
6e7631eb08
@ -54,11 +54,6 @@ public class Main {
|
|||||||
if (Utils.isRunningOnRaspberry() && !Utils.isInArray("-noraspi", args) && isRaspi) {
|
if (Utils.isRunningOnRaspberry() && !Utils.isInArray("-noraspi", args) && isRaspi) {
|
||||||
Gpio.wiringPiSetupPhys();
|
Gpio.wiringPiSetupPhys();
|
||||||
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
|
Gpio.pinMode(12, Gpio.PWM_OUTPUT);
|
||||||
try {
|
|
||||||
Files.createFile(Paths.get("/boot/warppi_loaded"));
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
StaticVars.screenPos = new int[] { 0, 0 };
|
StaticVars.screenPos = new int[] { 0, 0 };
|
||||||
StaticVars.debugOn = true;
|
StaticVars.debugOn = true;
|
||||||
|
@ -13,8 +13,17 @@ public class StaticVars {
|
|||||||
public static int outputLevel = 0;
|
public static int outputLevel = 0;
|
||||||
public static boolean debugWindow2x = false;
|
public static boolean debugWindow2x = false;
|
||||||
public static Class<?> classLoader;
|
public static Class<?> classLoader;
|
||||||
|
public static float windowZoom = 2;
|
||||||
|
|
||||||
private StaticVars() {
|
private StaticVars() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getCurrentZoomValue() {
|
||||||
|
if (StaticVars.debugOn & StaticVars.debugWindow2x) {
|
||||||
|
return 2;
|
||||||
|
} else {
|
||||||
|
return StaticVars.windowZoom;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,5 @@ public enum Key {
|
|||||||
PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT,
|
PLUS, MINUS, PLUS_MINUS, MULTIPLY, DIVIDE, EQUAL, DELETE, RESET, LEFT, RIGHT,
|
||||||
UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2,
|
UP, DOWN, OK, debug1, debug2, debug3, debug4, debug5, SQRT, ROOT, POWER_OF_2,
|
||||||
POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI, SETTINGS,
|
POWER_OF_x, SINE, COSINE, TANGENT, ARCSINE, ARCCOSINE, ARCTANGENT, PI, SETTINGS,
|
||||||
F1, F2, F3, F4, BACK
|
F1, F2, F3, F4, BACK, ZOOM_MODE
|
||||||
}
|
}
|
@ -178,7 +178,7 @@ public class Keyboard {
|
|||||||
} else if (!Keyboard.shift && !Keyboard.alpha) {
|
} else if (!Keyboard.shift && !Keyboard.alpha) {
|
||||||
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE);
|
Keyboard.keyPressed(Key.BRIGHTNESS_CYCLE);
|
||||||
} else {
|
} else {
|
||||||
Keyboard.keyPressed(Key.NONE);
|
Keyboard.keyPressed(Key.ZOOM_MODE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case com.jogamp.newt.event.KeyEvent.VK_ENTER:
|
case com.jogamp.newt.event.KeyEvent.VK_ENTER:
|
||||||
@ -463,7 +463,7 @@ public class Keyboard {
|
|||||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,3 */
|
{Key.NONE, Key.NONE, Key.NONE}, /* 0,3 */
|
||||||
{Key.NONE, Key.NONE, Key.NONE}, /* 0,4 */
|
{Key.NONE, Key.NONE, Key.NONE}, /* 0,4 */
|
||||||
{Key.SETTINGS, 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.BRIGHTNESS_CYCLE, Key.BRIGHTNESS_CYCLE_REVERSE, Key.ZOOM_MODE}, /* 0,6 */
|
||||||
{Key.SIMPLIFY, Key.STEP, Key.NONE} /* 0,7 */
|
{Key.SIMPLIFY, Key.STEP, Key.NONE} /* 0,7 */
|
||||||
},
|
},
|
||||||
{ /* ROW 1 */
|
{ /* ROW 1 */
|
||||||
@ -603,6 +603,9 @@ public class Keyboard {
|
|||||||
DisplayManager.INSTANCE.cycleBrightness(true);
|
DisplayManager.INSTANCE.cycleBrightness(true);
|
||||||
refresh = true;
|
refresh = true;
|
||||||
break;
|
break;
|
||||||
|
case ZOOM_MODE:
|
||||||
|
StaticVars.windowZoom = ((StaticVars.windowZoom - 0.5f) % 2f) + 1f;
|
||||||
|
refresh = true;
|
||||||
case HISTORY_BACK:
|
case HISTORY_BACK:
|
||||||
DisplayManager.INSTANCE.goBack();
|
DisplayManager.INSTANCE.goBack();
|
||||||
refresh = true;
|
refresh = true;
|
||||||
@ -704,7 +707,7 @@ Keyboard:
|
|||||||
|0,0-----|0,1-----|########|0,3-----|########|0,5-----|0,6-----|
|
|0,0-----|0,1-----|########|0,3-----|########|0,5-----|0,6-----|
|
||||||
| SHIFT | ALPHA |########| ^ |########|SETTINGS|+BRIGHT |
|
| SHIFT | ALPHA |########| ^ |########|SETTINGS|+BRIGHT |
|
||||||
| NORMAL | ALPHA |########| |########| |-BRIGHT |
|
| NORMAL | ALPHA |########| |########| |-BRIGHT |
|
||||||
| SHIFT | NORMAL |########| |########| | |
|
| SHIFT | NORMAL |########| |########| |ZOOMMODE|
|
||||||
|1,0-----|1,1-----|1,2-----|1,3-----|1,4-----|1,5-----|1,6-----|
|
|1,0-----|1,1-----|1,2-----|1,3-----|1,4-----|1,5-----|1,6-----|
|
||||||
| F_4 | | < | OK | > | Back | Fwd |
|
| F_4 | | < | OK | > | Back | Fwd |
|
||||||
| F_4 | | | | | | |
|
| F_4 | | | | | | |
|
||||||
|
@ -39,8 +39,8 @@ public class SwingWindow extends JFrame {
|
|||||||
// Transparent 16 x 16 pixel cursor image.
|
// Transparent 16 x 16 pixel cursor image.
|
||||||
final BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
final BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
|
||||||
|
|
||||||
|
if ((StaticVars.windowZoom != 1) | (StaticVars.debugOn & StaticVars.debugWindow2x)) mult = 2;
|
||||||
if (StaticVars.debugOn) {
|
if (StaticVars.debugOn) {
|
||||||
if (StaticVars.debugWindow2x) mult = 2;
|
|
||||||
if (Utils.debugThirdScreen) {
|
if (Utils.debugThirdScreen) {
|
||||||
this.setLocation(2880, 900);
|
this.setLocation(2880, 900);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
@ -57,7 +57,7 @@ public class GPUEngine implements GraphicEngine {
|
|||||||
public void setDisplayMode(int ww, int wh) {
|
public void setDisplayMode(int ww, int wh) {
|
||||||
size[0] = ww;
|
size[0] = ww;
|
||||||
size[1] = wh;
|
size[1] = wh;
|
||||||
wnd.window.setSize((StaticVars.debugOn & StaticVars.debugWindow2x) ? ww * 2 : ww, (StaticVars.debugOn & StaticVars.debugWindow2x) ? wh * 2 : wh);
|
wnd.window.setSize(ww, wh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -28,6 +28,10 @@
|
|||||||
|
|
||||||
package org.warp.picalculator.gui.graphicengine.gpu;
|
package org.warp.picalculator.gui.graphicengine.gpu;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
|
||||||
import org.warp.picalculator.StaticVars;
|
import org.warp.picalculator.StaticVars;
|
||||||
import org.warp.picalculator.device.Key;
|
import org.warp.picalculator.device.Key;
|
||||||
import org.warp.picalculator.device.Keyboard;
|
import org.warp.picalculator.device.Keyboard;
|
||||||
@ -60,11 +64,14 @@ class NEWTWindow implements GLEventListener {
|
|||||||
|
|
||||||
private final GPUEngine disp;
|
private final GPUEngine disp;
|
||||||
private final GPURenderer renderer;
|
private final GPURenderer renderer;
|
||||||
|
public float windowZoom;
|
||||||
|
public int[] realWindowSize;
|
||||||
public Runnable onInitialized;
|
public Runnable onInitialized;
|
||||||
|
|
||||||
public NEWTWindow(GPUEngine disp) {
|
public NEWTWindow(GPUEngine disp) {
|
||||||
this.disp = disp;
|
this.disp = disp;
|
||||||
renderer = disp.getRenderer();
|
renderer = disp.getRenderer();
|
||||||
|
realWindowSize = new int[] {1,1};
|
||||||
}
|
}
|
||||||
|
|
||||||
public GLWindow window;
|
public GLWindow window;
|
||||||
@ -173,7 +180,7 @@ class NEWTWindow implements GLEventListener {
|
|||||||
} else if (!Keyboard.shift && !Keyboard.alpha) {
|
} else if (!Keyboard.shift && !Keyboard.alpha) {
|
||||||
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE);
|
Keyboard.keyReleased(Key.BRIGHTNESS_CYCLE);
|
||||||
} else {
|
} else {
|
||||||
Keyboard.keyReleased(Key.NONE);
|
Keyboard.keyReleased(Key.ZOOM_MODE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KeyEvent.VK_ENTER:
|
case KeyEvent.VK_ENTER:
|
||||||
@ -284,7 +291,7 @@ class NEWTWindow implements GLEventListener {
|
|||||||
final GL2ES1 gl = drawable.getGL().getGL2ES1();
|
final GL2ES1 gl = drawable.getGL().getGL2ES1();
|
||||||
|
|
||||||
//Vsync
|
//Vsync
|
||||||
gl.setSwapInterval(2);
|
gl.setSwapInterval(1);
|
||||||
|
|
||||||
//Textures
|
//Textures
|
||||||
gl.glEnable(GL.GL_TEXTURE_2D);
|
gl.glEnable(GL.GL_TEXTURE_2D);
|
||||||
@ -313,22 +320,32 @@ class NEWTWindow implements GLEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
|
public void reshape(GLAutoDrawable glad, int x, int y, int width, int height) {
|
||||||
disp.size[0] = (StaticVars.debugOn & StaticVars.debugWindow2x) ? width / 2 : width;
|
realWindowSize[0] = width;
|
||||||
disp.size[1] = (StaticVars.debugOn & StaticVars.debugWindow2x) ? height / 2 : height;
|
realWindowSize[1] = height;
|
||||||
|
disp.size[0] = width;
|
||||||
|
disp.size[1] = height;
|
||||||
final GL2ES1 gl = glad.getGL().getGL2ES1();
|
final GL2ES1 gl = glad.getGL().getGL2ES1();
|
||||||
if (width == 0) {
|
|
||||||
width = 1;
|
onZoomChanged(gl, true);
|
||||||
}
|
|
||||||
if (height == 0) {
|
|
||||||
height = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onZoomChanged(GL2ES1 gl, boolean sizeChanged) {
|
||||||
|
float precWindowZoom = windowZoom;
|
||||||
|
windowZoom = StaticVars.getCurrentZoomValue();
|
||||||
|
System.out.println("sizechange" + windowZoom);
|
||||||
|
|
||||||
|
final int width = realWindowSize[0];
|
||||||
|
final int height = realWindowSize[1];
|
||||||
|
|
||||||
|
disp.size[0] = (int) (realWindowSize[0] / windowZoom);
|
||||||
|
disp.size[1] = (int) (realWindowSize[1] / windowZoom);
|
||||||
|
|
||||||
gl.glViewport(0, 0, width, height);
|
gl.glViewport(0, 0, width, height);
|
||||||
|
|
||||||
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
|
gl.glMatrixMode(GLMatrixFunc.GL_PROJECTION);
|
||||||
gl.glLoadIdentity();
|
gl.glLoadIdentity();
|
||||||
|
|
||||||
gl.glOrtho(0.0, (StaticVars.debugOn & StaticVars.debugWindow2x) ? width / 2 : width, (StaticVars.debugOn & StaticVars.debugWindow2x) ? height / 2 : height, 0.0, -1, 1);
|
gl.glOrtho(0.0, disp.size[0], disp.size[1], 0.0, -1, 1);
|
||||||
|
|
||||||
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
gl.glMatrixMode(GLMatrixFunc.GL_MODELVIEW);
|
||||||
gl.glLoadIdentity();
|
gl.glLoadIdentity();
|
||||||
@ -340,6 +357,10 @@ class NEWTWindow implements GLEventListener {
|
|||||||
|
|
||||||
GPURenderer.gl = gl;
|
GPURenderer.gl = gl;
|
||||||
|
|
||||||
|
if (windowZoom != StaticVars.getCurrentZoomValue()) {
|
||||||
|
onZoomChanged(gl, false);
|
||||||
|
}
|
||||||
|
|
||||||
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
|
gl.glEnableClientState(GLPointerFunc.GL_COLOR_ARRAY);
|
||||||
gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
|
gl.glEnableClientState(GLPointerFunc.GL_VERTEX_ARRAY);
|
||||||
gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
|
gl.glEnableClientState(GLPointerFunc.GL_TEXTURE_COORD_ARRAY);
|
||||||
|
@ -37,6 +37,7 @@ public class NoGuiEngine implements GraphicEngine {
|
|||||||
public void setDisplayMode(int ww, int wh) {
|
public void setDisplayMode(int ww, int wh) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create(Runnable onInitialized) {
|
public void create(Runnable onInitialized) {
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
@ -11,6 +11,7 @@ public class LoadingScreen extends Screen {
|
|||||||
boolean mustRefresh = true;
|
boolean mustRefresh = true;
|
||||||
public float loadingTextTranslation = 0.0f;
|
public float loadingTextTranslation = 0.0f;
|
||||||
public boolean loaded = false;
|
public boolean loaded = false;
|
||||||
|
private float previousZoomValue = 1;
|
||||||
|
|
||||||
public LoadingScreen() {
|
public LoadingScreen() {
|
||||||
super();
|
super();
|
||||||
@ -23,7 +24,10 @@ public class LoadingScreen extends Screen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialized() throws InterruptedException {}
|
public void initialized() throws InterruptedException {
|
||||||
|
previousZoomValue = StaticVars.getCurrentZoomValue();
|
||||||
|
StaticVars.windowZoom = 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void beforeRender(float dt) {
|
public void beforeRender(float dt) {
|
||||||
@ -31,6 +35,7 @@ public class LoadingScreen extends Screen {
|
|||||||
|
|
||||||
endLoading += dt;
|
endLoading += dt;
|
||||||
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
|
if (loaded && (StaticVars.debugOn || endLoading >= 3.5f)) {
|
||||||
|
StaticVars.windowZoom = previousZoomValue;
|
||||||
DisplayManager.INSTANCE.setScreen(new MathInputScreen());
|
DisplayManager.INSTANCE.setScreen(new MathInputScreen());
|
||||||
}
|
}
|
||||||
mustRefresh = true;
|
mustRefresh = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user