mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 07:05:40 +12:00
Even more peach stuff
This commit is contained in:
parent
a78a1a099f
commit
e6880b1564
4 changed files with 17 additions and 6 deletions
|
@ -15,19 +15,24 @@ bool romLoaded = false;
|
||||||
|
|
||||||
#define AlberFunction(type, name) JNIEXPORT type JNICALL Java_com_panda3ds_pandroid_AlberDriver_##name
|
#define AlberFunction(type, name) JNIEXPORT type JNICALL Java_com_panda3ds_pandroid_AlberDriver_##name
|
||||||
|
|
||||||
|
void throwException(JNIEnv* env, const char* message) {
|
||||||
|
jclass exceptionClass = env->FindClass("java/lang/RuntimeException");
|
||||||
|
env->ThrowNew(exceptionClass, message);
|
||||||
|
}
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) {
|
AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) {
|
||||||
emulator = std::make_unique<Emulator>();
|
emulator = std::make_unique<Emulator>();
|
||||||
|
|
||||||
if (emulator->getRendererType() != RendererType::OpenGL) {
|
if (emulator->getRendererType() != RendererType::OpenGL) {
|
||||||
throw std::runtime_error("Renderer is not OpenGL");
|
return throwException(env, "Renderer type is not OpenGL");
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer = static_cast<RendererGL*>(emulator->getRenderer());
|
renderer = static_cast<RendererGL*>(emulator->getRenderer());
|
||||||
hidService = &emulator->getServiceManager().getHID();
|
hidService = &emulator->getServiceManager().getHID();
|
||||||
|
|
||||||
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(eglGetProcAddress))) {
|
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(eglGetProcAddress))) {
|
||||||
throw std::runtime_error("OpenGL ES init failed");
|
return throwException(env, "Failed to load OpenGL ES 2.0");
|
||||||
}
|
}
|
||||||
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor);
|
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor);
|
||||||
|
@ -36,6 +41,7 @@ AlberFunction(void, Initialize)(JNIEnv* env, jobject obj) {
|
||||||
|
|
||||||
AlberFunction(void, RunFrame)(JNIEnv* env, jobject obj, jint fbo) {
|
AlberFunction(void, RunFrame)(JNIEnv* env, jobject obj, jint fbo) {
|
||||||
renderer->setFBO(fbo);
|
renderer->setFBO(fbo);
|
||||||
|
// TODO: don't reset entire state manager
|
||||||
renderer->resetStateManager();
|
renderer->resetStateManager();
|
||||||
emulator->runFrame();
|
emulator->runFrame();
|
||||||
|
|
||||||
|
@ -53,7 +59,6 @@ AlberFunction(jboolean, HasRomLoaded)(JNIEnv* env, jobject obj) { return romLoad
|
||||||
AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) {
|
AlberFunction(void, LoadRom)(JNIEnv* env, jobject obj, jstring path) {
|
||||||
const char* pathStr = env->GetStringUTFChars(path, nullptr);
|
const char* pathStr = env->GetStringUTFChars(path, nullptr);
|
||||||
romLoaded = emulator->loadROM(pathStr);
|
romLoaded = emulator->loadROM(pathStr);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "Loading ROM %s, result: %d", pathStr, (int)romLoaded);
|
|
||||||
env->ReleaseStringUTFChars(path, pathStr);
|
env->ReleaseStringUTFChars(path, pathStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,8 @@ public class Constants {
|
||||||
public static final int INPUT_KEY_Y = 1 << 11;
|
public static final int INPUT_KEY_Y = 1 << 11;
|
||||||
|
|
||||||
public static final int N3DS_WIDTH = 400;
|
public static final int N3DS_WIDTH = 400;
|
||||||
public static final int N3DS_HALF_HEIGHT = 240;
|
public static final int N3DS_FULL_HEIGHT = 480;
|
||||||
public static final int N3DS_FULL_HEIGHT = N3DS_HALF_HEIGHT * 2;
|
public static final int N3DS_HALF_HEIGHT = N3DS_FULL_HEIGHT / 2;
|
||||||
|
|
||||||
public static final String ACTIVITY_PARAMETER_PATH = "path";
|
public static final String ACTIVITY_PARAMETER_PATH = "path";
|
||||||
public static final String LOG_TAG = "pandroid";
|
public static final String LOG_TAG = "pandroid";
|
||||||
|
|
|
@ -69,6 +69,9 @@ public class PandaGlRenderer implements GLSurfaceView.Renderer, ConsoleRenderer
|
||||||
screenFbo = generateBuffer[0];
|
screenFbo = generateBuffer[0];
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, screenFbo);
|
glBindFramebuffer(GL_FRAMEBUFFER, screenFbo);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, screenTexture, 0);
|
||||||
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
|
Log.e(Constants.LOG_TAG, "Framebuffer is not complete");
|
||||||
|
}
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
AlberDriver.Initialize();
|
AlberDriver.Initialize();
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.panda3ds.pandroid.view;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.opengl.GLSurfaceView;
|
import android.opengl.GLSurfaceView;
|
||||||
|
import android.os.Debug;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import com.panda3ds.pandroid.math.Vector2;
|
import com.panda3ds.pandroid.math.Vector2;
|
||||||
|
@ -17,7 +18,9 @@ public class PandaGlSurfaceView extends GLSurfaceView implements TouchScreenNode
|
||||||
public PandaGlSurfaceView(Context context, String romPath) {
|
public PandaGlSurfaceView(Context context, String romPath) {
|
||||||
super(context);
|
super(context);
|
||||||
setEGLContextClientVersion(3);
|
setEGLContextClientVersion(3);
|
||||||
|
if (Debug.isDebuggerConnected()) {
|
||||||
setDebugFlags(DEBUG_LOG_GL_CALLS);
|
setDebugFlags(DEBUG_LOG_GL_CALLS);
|
||||||
|
}
|
||||||
renderer = new PandaGlRenderer(romPath);
|
renderer = new PandaGlRenderer(romPath);
|
||||||
setRenderer(renderer);
|
setRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue