Merge pull request #327 from wheremyfoodat/hydra-icon

Minor hydra gl interface fixup
This commit is contained in:
wheremyfoodat 2023-10-25 23:54:56 +03:00 committed by GitHub
commit 0125dbe31a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 9 deletions

View file

@ -18,8 +18,9 @@ class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRend
void setOutputSize(hydra::Size size) override; void setOutputSize(hydra::Size size) override;
// IOpenGlRendered // IOpenGlRendered
void resetContext() override;
void destroyContext() override;
void setFbo(unsigned handle) override; void setFbo(unsigned handle) override;
void setContext(void* context) override;
void setGetProcAddress(void* function) override; void setGetProcAddress(void* function) override;
// IFrontendDriven // IFrontendDriven
@ -34,6 +35,7 @@ class HC_GLOBAL HydraCore final : public hydra::IBase, public hydra::IOpenGlRend
RendererGL* renderer; RendererGL* renderer;
void (*pollInputCallback)() = nullptr; void (*pollInputCallback)() = nullptr;
int32_t (*checkButtonCallback)(uint32_t player, hydra::ButtonType button) = nullptr; int32_t (*checkButtonCallback)(uint32_t player, hydra::ButtonType button) = nullptr;
void* getProcAddress = nullptr;
}; };
HydraCore::HydraCore() : emulator(new Emulator) { HydraCore::HydraCore() : emulator(new Emulator) {
@ -88,7 +90,6 @@ void HydraCore::runFrame() {
} }
hid.updateInputs(emulator->getTicks()); hid.updateInputs(emulator->getTicks());
emulator->runFrame(); 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 // Size doesn't matter as the glBlitFramebuffer call is commented out for the core
void HydraCore::setOutputSize(hydra::Size size) {} void HydraCore::setOutputSize(hydra::Size size) {}
void HydraCore::setGetProcAddress(void* function) { void HydraCore::resetContext() {
#ifdef __ANDROID__ #ifdef __ANDROID__
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(function))) { if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(getProcAddress))) {
Helpers::panic("OpenGL ES init failed"); Helpers::panic("OpenGL ES init failed");
} }
#else #else
if (!gladLoadGLLoader(reinterpret_cast<GLADloadproc>(function))) { if (!gladLoadGLLoader(reinterpret_cast<GLADloadproc>(getProcAddress))) {
Helpers::panic("OpenGL init failed"); Helpers::panic("OpenGL init failed");
} }
#endif #endif
@ -114,13 +115,14 @@ void HydraCore::setGetProcAddress(void* function) {
emulator->initGraphicsContext(nullptr); emulator->initGraphicsContext(nullptr);
} }
void HydraCore::setContext(void*) {} void HydraCore::destroyContext() { emulator->deinitGraphicsContext(); }
void HydraCore::setFbo(unsigned handle) { renderer->setFBO(handle); } void HydraCore::setFbo(unsigned handle) { renderer->setFBO(handle); }
void HydraCore::setGetProcAddress(void* function) { getProcAddress = function; }
void HydraCore::setPollInputCallback(void (*callback)()) { pollInputCallback = callback; } void HydraCore::setPollInputCallback(void (*callback)()) { pollInputCallback = callback; }
void HydraCore::setCheckButtonCallback(int32_t (*callback)(uint32_t player, hydra::ButtonType button)) { checkButtonCallback = 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 void destroyEmulator(hydra::IBase* emulator) { delete emulator; }
HC_API const char* getInfo(hydra::InfoType type) { HC_API const char* getInfo(hydra::InfoType type) {

@ -1 +1 @@
Subproject commit e4cc6b0fc224583e509bc3472a4c11eafb69c041 Subproject commit 1cdb1eda5f368481e216416a119c85664e8c72ab