diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index a82f4bf8..70750d2c 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -2,38 +2,31 @@ package com.panda3ds.pandroid.app; import android.content.Intent; import android.os.Bundle; -import android.os.Handler; -import android.util.Log; +import android.widget.FrameLayout; import android.widget.Toast; import androidx.annotation.Nullable; -import com.panda3ds.pandroid.AlberDriver; -import com.panda3ds.pandroid.C; -import com.panda3ds.pandroid.app.BaseActivity; +import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.view.PandaGlSurfaceView; public class GameActivity extends BaseActivity { private PandaGlSurfaceView pandaSurface; - @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); - pandaSurface = new PandaGlSurfaceView(this);; - setContentView(pandaSurface); Intent intent = getIntent(); - if(!intent.hasExtra(C.EXTRA_PATH)){ + if(!intent.hasExtra(Constants.EXTRA_PATH)){ + + setContentView(new FrameLayout(this)); Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show(); finish(); return; } - pandaSurface.getRenderer().postDrawEvent(()->{ - String path = intent.getStringExtra(C.EXTRA_PATH); - Log.i(C.LOG_TAG,"Try load ROM: "+path); - AlberDriver.LoadRom(path); - }); + pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));; + setContentView(pandaSurface); } } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java index 6acce7fd..616daf13 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/MainActivity.java @@ -10,7 +10,7 @@ import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; -import com.panda3ds.pandroid.C; +import com.panda3ds.pandroid.utils.Constants; import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.utils.PathUtils; @@ -48,7 +48,7 @@ public class MainActivity extends AppCompatActivity { String path = PathUtils.getPath(getApplicationContext(), data.getData()); Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show(); startActivity(new Intent(this, GameActivity.class) - .putExtra(C.EXTRA_PATH, path)); + .putExtra(Constants.EXTRA_PATH, path)); } super.onActivityResult(requestCode, resultCode, data); } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/C.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java similarity index 62% rename from src/pandroid/app/src/main/java/com/panda3ds/pandroid/C.java rename to src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java index 722a7235..b4cf805e 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/C.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/utils/Constants.java @@ -1,6 +1,6 @@ -package com.panda3ds.pandroid; +package com.panda3ds.pandroid.utils; -public class C { +public class Constants { public static final String EXTRA_PATH = "path"; public static final String LOG_TAG = "Alber"; } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java index 9ad8e34e..3cf5407f 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlRenderer.java @@ -7,25 +7,22 @@ import static android.opengl.GLES32.*; import android.content.res.Resources; import android.opengl.GLSurfaceView; -import android.util.DisplayMetrics; import android.util.Log; import com.panda3ds.pandroid.AlberDriver; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; import java.util.ArrayList; public class PandaGlRenderer implements GLSurfaceView.Renderer { - private final ArrayList events = new ArrayList<>(); + private final String romPath; int screenWidth, screenHeight; int screenTexture; public int screenFbo; - PandaGlRenderer() { + PandaGlRenderer(String romPath) { super(); + this.romPath = romPath; } @@ -65,10 +62,7 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer { glBindFramebuffer(GL_FRAMEBUFFER, 0); AlberDriver.Initialize(); - } - - public void postDrawEvent(Runnable callback){ - events.add(callback); + AlberDriver.LoadRom(romPath); } public void onDrawFrame(GL10 unused) { @@ -78,13 +72,6 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer { glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo); glBlitFramebuffer(0, 0, 400, 480, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR); } - - int count = events.size(); - while (count > 0){ - events.get(0).run(); - events.remove(0); - count--; - } } public void onSurfaceChanged(GL10 unused, int width, int height) { diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java index a26b3d2f..35805657 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/PandaGlSurfaceView.java @@ -6,10 +6,11 @@ import android.opengl.GLSurfaceView; public class PandaGlSurfaceView extends GLSurfaceView { final PandaGlRenderer renderer; - public PandaGlSurfaceView(Context context) { + public PandaGlSurfaceView(Context context, String romPath) { super(context); setEGLContextClientVersion(3); - renderer = new PandaGlRenderer(); + setDebugFlags(DEBUG_LOG_GL_CALLS); + renderer = new PandaGlRenderer(romPath); setRenderer(renderer); }