mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-28 13:15:55 +00:00
.
This commit is contained in:
parent
367701b325
commit
ce6fa0043a
5 changed files with 18 additions and 37 deletions
|
@ -2,38 +2,31 @@ package com.panda3ds.pandroid.app;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.widget.FrameLayout;
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.panda3ds.pandroid.AlberDriver;
|
import com.panda3ds.pandroid.utils.Constants;
|
||||||
import com.panda3ds.pandroid.C;
|
|
||||||
import com.panda3ds.pandroid.app.BaseActivity;
|
|
||||||
import com.panda3ds.pandroid.view.PandaGlSurfaceView;
|
import com.panda3ds.pandroid.view.PandaGlSurfaceView;
|
||||||
|
|
||||||
public class GameActivity extends BaseActivity {
|
public class GameActivity extends BaseActivity {
|
||||||
private PandaGlSurfaceView pandaSurface;
|
private PandaGlSurfaceView pandaSurface;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
pandaSurface = new PandaGlSurfaceView(this);;
|
|
||||||
setContentView(pandaSurface);
|
|
||||||
|
|
||||||
Intent intent = getIntent();
|
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();
|
Toast.makeText(this, "INVALID ROM PATH", Toast.LENGTH_LONG).show();
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pandaSurface.getRenderer().postDrawEvent(()->{
|
pandaSurface = new PandaGlSurfaceView(this, intent.getStringExtra(Constants.EXTRA_PATH));;
|
||||||
String path = intent.getStringExtra(C.EXTRA_PATH);
|
setContentView(pandaSurface);
|
||||||
Log.i(C.LOG_TAG,"Try load ROM: "+path);
|
|
||||||
AlberDriver.LoadRom(path);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
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.R;
|
||||||
import com.panda3ds.pandroid.utils.PathUtils;
|
import com.panda3ds.pandroid.utils.PathUtils;
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
String path = PathUtils.getPath(getApplicationContext(), data.getData());
|
String path = PathUtils.getPath(getApplicationContext(), data.getData());
|
||||||
Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show();
|
Toast.makeText(getApplicationContext(), "pandroid opening " + path, Toast.LENGTH_LONG).show();
|
||||||
startActivity(new Intent(this, GameActivity.class)
|
startActivity(new Intent(this, GameActivity.class)
|
||||||
.putExtra(C.EXTRA_PATH, path));
|
.putExtra(Constants.EXTRA_PATH, path));
|
||||||
}
|
}
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 EXTRA_PATH = "path";
|
||||||
public static final String LOG_TAG = "Alber";
|
public static final String LOG_TAG = "Alber";
|
||||||
}
|
}
|
|
@ -7,25 +7,22 @@ import static android.opengl.GLES32.*;
|
||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
import android.util.DisplayMetrics;
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.panda3ds.pandroid.AlberDriver;
|
import com.panda3ds.pandroid.AlberDriver;
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.nio.ByteOrder;
|
|
||||||
import java.nio.FloatBuffer;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class PandaGlRenderer implements GLSurfaceView.Renderer {
|
public class PandaGlRenderer implements GLSurfaceView.Renderer {
|
||||||
|
|
||||||
private final ArrayList<Runnable> events = new ArrayList<>();
|
private final String romPath;
|
||||||
int screenWidth, screenHeight;
|
int screenWidth, screenHeight;
|
||||||
int screenTexture;
|
int screenTexture;
|
||||||
public int screenFbo;
|
public int screenFbo;
|
||||||
|
|
||||||
PandaGlRenderer() {
|
PandaGlRenderer(String romPath) {
|
||||||
super();
|
super();
|
||||||
|
this.romPath = romPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,10 +62,7 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
AlberDriver.Initialize();
|
AlberDriver.Initialize();
|
||||||
}
|
AlberDriver.LoadRom(romPath);
|
||||||
|
|
||||||
public void postDrawEvent(Runnable callback){
|
|
||||||
events.add(callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDrawFrame(GL10 unused) {
|
public void onDrawFrame(GL10 unused) {
|
||||||
|
@ -78,13 +72,6 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, screenFbo);
|
||||||
glBlitFramebuffer(0, 0, 400, 480, 0, 0, screenWidth, screenHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
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) {
|
public void onSurfaceChanged(GL10 unused, int width, int height) {
|
||||||
|
|
|
@ -6,10 +6,11 @@ import android.opengl.GLSurfaceView;
|
||||||
public class PandaGlSurfaceView extends GLSurfaceView {
|
public class PandaGlSurfaceView extends GLSurfaceView {
|
||||||
final PandaGlRenderer renderer;
|
final PandaGlRenderer renderer;
|
||||||
|
|
||||||
public PandaGlSurfaceView(Context context) {
|
public PandaGlSurfaceView(Context context, String romPath) {
|
||||||
super(context);
|
super(context);
|
||||||
setEGLContextClientVersion(3);
|
setEGLContextClientVersion(3);
|
||||||
renderer = new PandaGlRenderer();
|
setDebugFlags(DEBUG_LOG_GL_CALLS);
|
||||||
|
renderer = new PandaGlRenderer(romPath);
|
||||||
setRenderer(renderer);
|
setRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue