diff --git a/include/emulator.hpp b/include/emulator.hpp index 83b832f6..ae6e7142 100644 --- a/include/emulator.hpp +++ b/include/emulator.hpp @@ -1,19 +1,22 @@ #pragma once #include -#include #include #include #include #include "PICA/gpu.hpp" -#include "cpu.hpp" #include "config.hpp" +#include "cpu.hpp" #include "crypto/aes_engine.hpp" #include "io_file.hpp" #include "memory.hpp" + +#if ENABLE_OPENGL #include "gl_state.hpp" +#endif + #ifdef PANDA3DS_ENABLE_HTTP_SERVER #include "httpserver.hpp" #endif @@ -27,10 +30,14 @@ class Emulator { Kernel kernel; Crypto::AESEngine aesEngine; - GLStateManager gl; EmulatorConfig config; SDL_Window* window; + +#if ENABLE_OPENGL SDL_GLContext glContext; + GLStateManager gl; +#endif + SDL_GameController* gameController = nullptr; int gameControllerID; diff --git a/src/emulator.cpp b/src/emulator.cpp index 0311f6e9..0d95b82b 100644 --- a/src/emulator.cpp +++ b/src/emulator.cpp @@ -2,6 +2,10 @@ #include +#if ENABLE_OPENGL +#include +#endif + #ifdef _WIN32 #include @@ -23,6 +27,7 @@ Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError()); } +#if ENABLE_OPENGL // Request OpenGL 4.1 Core (Max available on MacOS) // MacOS gets mad if we don't explicitly demand a core profile SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); @@ -42,6 +47,7 @@ Emulator::Emulator() : kernel(cpu, memory, gpu), cpu(memory, kernel), gpu(memory if (!gladLoadGL(reinterpret_cast(SDL_GL_GetProcAddress))) { Helpers::panic("OpenGL init failed: %s", SDL_GetError()); } +#endif if (SDL_WasInit(SDL_INIT_GAMECONTROLLER)) { gameController = SDL_GameControllerOpen(0); @@ -428,13 +434,16 @@ bool Emulator::loadELF(std::ifstream& file) { // Reset our graphics context and initialize the GPU's graphics context void Emulator::initGraphicsContext() { +#if ENABLE_OPENGL gl.reset(); // TODO (For when we have multiple backends): Only do this if we are using OpenGL +#endif gpu.initGraphicsContext(); } #ifdef PANDA3DS_ENABLE_HTTP_SERVER void Emulator::pollHttpServer() { std::scoped_lock lock(httpServer.actionMutex); + ServiceManager& srv = kernel.getServiceManager(); if (httpServer.pendingAction) {