v0.4.2: reintroduced scissoring, now only used when its needed
This commit is contained in:
parent
275dcf8863
commit
23ac0135f3
|
@ -36,7 +36,9 @@ public class Camera extends Gizmo {
|
|||
protected static float invH2;
|
||||
|
||||
public static Camera main;
|
||||
|
||||
|
||||
public boolean fullScreen;
|
||||
|
||||
public float zoom;
|
||||
|
||||
public int x;
|
||||
|
@ -101,10 +103,12 @@ public class Camera extends Gizmo {
|
|||
public static Camera createFullscreen( float zoom ) {
|
||||
int w = (int)Math.ceil( Game.width / zoom );
|
||||
int h = (int)Math.ceil( Game.height / zoom );
|
||||
return new Camera(
|
||||
(int)(Game.width - w * zoom) / 2,
|
||||
(int)(Game.height - h * zoom) / 2,
|
||||
w, h, zoom );
|
||||
Camera c = new Camera(
|
||||
(int)(Game.width - w * zoom) / 2,
|
||||
(int)(Game.height - h * zoom) / 2,
|
||||
w, h, zoom );
|
||||
c.fullScreen = true;
|
||||
return c;
|
||||
}
|
||||
|
||||
public Camera( int x, int y, int width, int height, float zoom ) {
|
||||
|
|
|
@ -217,6 +217,7 @@ public class Game extends Activity implements GLSurfaceView.Renderer, View.OnTou
|
|||
|
||||
NoosaScript.get().resetCamera();
|
||||
NoosaScriptNoLighting.get().resetCamera();
|
||||
GLES20.glDisable( GLES20.GL_SCISSOR_TEST );
|
||||
GLES20.glClear( GLES20.GL_COLOR_BUFFER_BIT );
|
||||
draw();
|
||||
}
|
||||
|
|
|
@ -179,6 +179,17 @@ public class NoosaScript extends Script {
|
|||
if (camera != lastCamera && camera.matrix != null) {
|
||||
lastCamera = camera;
|
||||
uCamera.valueM4( camera.matrix );
|
||||
|
||||
if (!camera.fullScreen) {
|
||||
GLES20.glEnable( GLES20.GL_SCISSOR_TEST );
|
||||
GLES20.glScissor(
|
||||
camera.x,
|
||||
Game.height - camera.screenHeight - camera.y,
|
||||
camera.screenWidth,
|
||||
camera.screenHeight);
|
||||
} else {
|
||||
GLES20.glDisable( GLES20.GL_SCISSOR_TEST );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -305,6 +305,7 @@ public class PixelScene extends Scene {
|
|||
(int)(Game.height - Math.ceil( Game.height / zoom ) * zoom) / 2,
|
||||
(int)Math.ceil( Game.width / zoom ),
|
||||
(int)Math.ceil( Game.height / zoom ), zoom );
|
||||
fullScreen = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue
Block a user