mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-08 12:01:39 +12:00
Various cleanups
This commit is contained in:
parent
c1162678bb
commit
200a884589
5 changed files with 21 additions and 20 deletions
|
@ -33,7 +33,7 @@ public class GameActivity extends BaseActivity {
|
||||||
if(!intent.hasExtra(Constants.EXTRA_PATH)){
|
if(!intent.hasExtra(Constants.EXTRA_PATH)){
|
||||||
|
|
||||||
setContentView(new FrameLayout(this));
|
setContentView(new FrameLayout(this));
|
||||||
Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show();
|
Toast.makeText(this, "Invalid rom path!", Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,9 +2,11 @@ package com.panda3ds.pandroid.math;
|
||||||
|
|
||||||
public class Vector2 {
|
public class Vector2 {
|
||||||
public float x,y;
|
public float x,y;
|
||||||
|
|
||||||
public Vector2(){
|
public Vector2(){
|
||||||
this(0.0f);
|
this(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2(float value){
|
public Vector2(float value){
|
||||||
this(value,value);
|
this(value,value);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +19,7 @@ public class Vector2 {
|
||||||
public float distanceTo(Vector2 vec){
|
public float distanceTo(Vector2 vec){
|
||||||
return distance(x,y,vec.x, vec.y);
|
return distance(x,y,vec.x, vec.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float distance(float x, float y, float x2, float y2){
|
public static float distance(float x, float y, float x2, float y2){
|
||||||
return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
|
return (float) Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ public class Constants {
|
||||||
public static final int INPUT_KEY_START = 1 << 3;
|
public static final int INPUT_KEY_START = 1 << 3;
|
||||||
public static final int INPUT_KEY_SELECT = 1 << 2;
|
public static final int INPUT_KEY_SELECT = 1 << 2;
|
||||||
|
|
||||||
|
public static final int N3DS_WIDTH = 400;
|
||||||
|
public static final int N3DS_HEIGHT = 240;
|
||||||
|
|
||||||
public static final String EXTRA_PATH = "path";
|
public static final String EXTRA_PATH = "path";
|
||||||
public static final String LOG_TAG = "Alber";
|
public static final String LOG_TAG = "Alber";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.opengl.GLSurfaceView;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.panda3ds.pandroid.AlberDriver;
|
import com.panda3ds.pandroid.AlberDriver;
|
||||||
|
import com.panda3ds.pandroid.utils.Constants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@ -69,43 +70,41 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer {
|
||||||
AlberDriver.RunFrame(screenFbo);
|
AlberDriver.RunFrame(screenFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo);
|
||||||
|
|
||||||
if (screenWidth > screenHeight) {
|
if (screenWidth > screenHeight) {
|
||||||
int topDisplayWidth = (int) ((screenHeight / 240.0) * 400);
|
int topDisplayWidth = (int)((screenHeight / (float)Constants.N3DS_HEIGHT) * Constants.N3DS_WIDTH);
|
||||||
int topDisplayHeight = screenHeight;
|
int topDisplayHeight = screenHeight;
|
||||||
|
|
||||||
if (topDisplayWidth > (screenWidth*0.7)){
|
if (topDisplayWidth > screenWidth * 0.7){
|
||||||
topDisplayWidth = (int) (screenWidth * 0.7);
|
topDisplayWidth = (int)(screenWidth * 0.7);
|
||||||
topDisplayHeight = (int) ((topDisplayWidth/400.0)*240);
|
topDisplayHeight = (int)((topDisplayWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int bottomDisplayHeight = (int) (((screenWidth-topDisplayWidth)/320)*240);
|
int bottomDisplayHeight = (int)(((screenWidth - topDisplayWidth) / 320) * Constants.N3DS_HEIGHT);
|
||||||
|
int topDisplayY = screenHeight - topDisplayHeight;
|
||||||
|
int bottomDisplayY = screenHeight - bottomDisplayHeight;
|
||||||
|
|
||||||
int topDisplayY = screenHeight-topDisplayHeight;
|
glBlitFramebuffer(0, Constants.N3DS_HEIGHT,
|
||||||
int bottomDisplayY = screenHeight-bottomDisplayHeight;
|
Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2,
|
||||||
|
|
||||||
glBlitFramebuffer(0, 240,
|
|
||||||
400, 480,
|
|
||||||
0, topDisplayY,
|
0, topDisplayY,
|
||||||
topDisplayWidth,topDisplayY+topDisplayHeight,
|
topDisplayWidth,topDisplayY+topDisplayHeight,
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
|
|
||||||
glBlitFramebuffer(
|
glBlitFramebuffer(
|
||||||
40, 0,
|
40, 0,
|
||||||
360, 240,
|
360, Constants.N3DS_HEIGHT,
|
||||||
topDisplayWidth, bottomDisplayY,
|
topDisplayWidth, bottomDisplayY,
|
||||||
screenWidth,bottomDisplayY+bottomDisplayHeight,
|
screenWidth,bottomDisplayY+bottomDisplayHeight,
|
||||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
} else {
|
} else {
|
||||||
int h = (int) ((screenWidth / 400.0) * 480);
|
int h = (int)((screenWidth / (float)Constants.N3DS_WIDTH) * Constants.N3DS_HEIGHT * 2);
|
||||||
glBlitFramebuffer(0, 0, 400, 480, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
glBlitFramebuffer(0, 0, Constants.N3DS_WIDTH, Constants.N3DS_HEIGHT * 2, 0, screenHeight - h, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceChanged(GL10 unused, int width, int height) {
|
public void onSurfaceChanged(GL10 unused, int width, int height) {
|
||||||
glViewport(0, 0, width, height);
|
|
||||||
screenWidth = width;
|
screenWidth = width;
|
||||||
screenHeight = height;
|
screenHeight = height;
|
||||||
glDisable(GL_SCISSOR_TEST);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,8 +13,4 @@ public class PandaGlSurfaceView extends GLSurfaceView {
|
||||||
renderer = new PandaGlRenderer(romPath);
|
renderer = new PandaGlRenderer(romPath);
|
||||||
setRenderer(renderer);
|
setRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PandaGlRenderer getRenderer() {
|
|
||||||
return renderer;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue