mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-09 12:31:40 +12:00
Add renderer/surface view files
This commit is contained in:
parent
469ae2805c
commit
a87397a214
6 changed files with 140 additions and 6 deletions
|
@ -1,11 +1,36 @@
|
|||
#include <jni.h>
|
||||
#include <stdexcept>
|
||||
#include <android/log.h>
|
||||
#include <EGL/egl.h>
|
||||
#include "renderer_gl/renderer_gl.hpp"
|
||||
#include "emulator.hpp"
|
||||
|
||||
std::unique_ptr<Emulator> emulator;
|
||||
std::unique_ptr<Emulator> emulator = nullptr;
|
||||
RendererGL* renderer = nullptr;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Initialize(JNIEnv* env, jobject obj) {
|
||||
__android_log_print(ANDROID_LOG_INFO, "Panda3DS", "Initializing Alber Driver");
|
||||
emulator = std::make_unique<Emulator>();
|
||||
__android_log_print(ANDROID_LOG_INFO, "Panda3DS", "Done");
|
||||
if (emulator->getRendererType() != RendererType::OpenGL) {
|
||||
throw std::runtime_error("Renderer is not OpenGL");
|
||||
}
|
||||
renderer = static_cast<RendererGL*>(emulator->getRenderer());
|
||||
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES Before %d.%d", GLVersion.major, GLVersion.minor);
|
||||
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(eglGetProcAddress))) {
|
||||
throw std::runtime_error("OpenGL ES init failed");
|
||||
}
|
||||
__android_log_print(ANDROID_LOG_INFO, "AlberDriver", "OpenGL ES %d.%d", GLVersion.major, GLVersion.minor);
|
||||
emulator->initGraphicsContext(nullptr);
|
||||
// girlboss it for now :3
|
||||
emulator->loadROM("/data/data/com.panda3ds.pandroid/files/rom.3ds");
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_RunFrame(JNIEnv* env, jobject obj, jint fbo) {
|
||||
renderer->setFBO(fbo);
|
||||
renderer->resetStateManager();
|
||||
emulator->runFrame();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_panda3ds_pandroid_AlberDriver_Finalize(JNIEnv* env, jobject obj) {
|
||||
emulator = nullptr;
|
||||
renderer = nullptr;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue