diff --git a/src/hydra_core.cpp b/src/hydra_core.cpp index 3c809dc3..3ecf7019 100644 --- a/src/hydra_core.cpp +++ b/src/hydra_core.cpp @@ -18,8 +18,9 @@ class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRend void setOutputSize(hydra::Size size) override; // IOpenGlRendered + void resetContext() override; + void destroyContext() override; void setFbo(unsigned handle) override; - void setContext(void* context) override; void setGetProcAddress(void* function) override; // IFrontendDriven @@ -34,6 +35,7 @@ class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRend RendererGL* renderer; void (*pollInputCallback)() = nullptr; int32_t (*checkButtonCallback)(uint32_t player, hydra::ButtonType button) = nullptr; + void* getProcAddress = nullptr; }; HydraCore::HydraCore() : emulator(new Emulator) { @@ -88,7 +90,6 @@ void HydraCore::runFrame() { } hid.updateInputs(emulator->getTicks()); - emulator->runFrame(); } @@ -100,13 +101,13 @@ hydra::Size HydraCore::getNativeSize() { return {400, 480}; } // Size doesn't matter as the glBlitFramebuffer call is commented out for the core void HydraCore::setOutputSize(hydra::Size size) {} -void HydraCore::setGetProcAddress(void* function) { +void HydraCore::resetContext() { #ifdef __ANDROID__ - if (!gladLoadGLES2Loader(reinterpret_cast(function))) { + if (!gladLoadGLES2Loader(reinterpret_cast(getProcAddress))) { Helpers::panic("OpenGL ES init failed"); } #else - if (!gladLoadGLLoader(reinterpret_cast(function))) { + if (!gladLoadGLLoader(reinterpret_cast(getProcAddress))) { Helpers::panic("OpenGL init failed"); } #endif @@ -114,13 +115,14 @@ void HydraCore::setGetProcAddress(void* function) { emulator->initGraphicsContext(nullptr); } -void HydraCore::setContext(void*) {} +void HydraCore::destroyContext() { emulator->deinitGraphicsContext(); } void HydraCore::setFbo(unsigned handle) { renderer->setFBO(handle); } +void HydraCore::setGetProcAddress(void* function) { getProcAddress = function; } void HydraCore::setPollInputCallback(void (*callback)()) { pollInputCallback = callback; } void HydraCore::setCheckButtonCallback(int32_t (*callback)(uint32_t player, hydra::ButtonType button)) { checkButtonCallback = callback; } -HC_API hydra::IBase* createEmulator() { return new HydraCore; } +HC_API hydra::IBase* createEmulator() { return new HydraCore(); } HC_API void destroyEmulator(hydra::IBase* emulator) { delete emulator; } HC_API const char* getInfo(hydra::InfoType type) { @@ -140,4 +142,4 @@ HC_API const char* getInfo(hydra::InfoType type) { default: return nullptr; } -} \ No newline at end of file +} diff --git a/third_party/hydra_core b/third_party/hydra_core index e4cc6b0f..1cdb1eda 160000 --- a/third_party/hydra_core +++ b/third_party/hydra_core @@ -1 +1 @@ -Subproject commit e4cc6b0fc224583e509bc3472a4c11eafb69c041 +Subproject commit 1cdb1eda5f368481e216416a119c85664e8c72ab