mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-08 23:25:40 +12:00
Emulator: Conditional OpenGL compilation
This commit is contained in:
parent
0009b0817d
commit
d664d5caf0
2 changed files with 19 additions and 3 deletions
|
@ -1,19 +1,22 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <glad/gl.h>
|
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
#include "PICA/gpu.hpp"
|
#include "PICA/gpu.hpp"
|
||||||
#include "cpu.hpp"
|
|
||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
#include "cpu.hpp"
|
||||||
#include "crypto/aes_engine.hpp"
|
#include "crypto/aes_engine.hpp"
|
||||||
#include "io_file.hpp"
|
#include "io_file.hpp"
|
||||||
#include "memory.hpp"
|
#include "memory.hpp"
|
||||||
|
|
||||||
|
#if ENABLE_OPENGL
|
||||||
#include "gl_state.hpp"
|
#include "gl_state.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
#include "httpserver.hpp"
|
#include "httpserver.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,10 +30,14 @@ class Emulator {
|
||||||
Kernel kernel;
|
Kernel kernel;
|
||||||
Crypto::AESEngine aesEngine;
|
Crypto::AESEngine aesEngine;
|
||||||
|
|
||||||
GLStateManager gl;
|
|
||||||
EmulatorConfig config;
|
EmulatorConfig config;
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
|
|
||||||
|
#if ENABLE_OPENGL
|
||||||
SDL_GLContext glContext;
|
SDL_GLContext glContext;
|
||||||
|
GLStateManager gl;
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_GameController* gameController = nullptr;
|
SDL_GameController* gameController = nullptr;
|
||||||
int gameControllerID;
|
int gameControllerID;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,10 @@
|
||||||
|
|
||||||
#include <stb_image_write.h>
|
#include <stb_image_write.h>
|
||||||
|
|
||||||
|
#if ENABLE_OPENGL
|
||||||
|
#include <glad/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -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());
|
Helpers::warn("Failed to initialize SDL2 GameController: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_OPENGL
|
||||||
// Request OpenGL 4.1 Core (Max available on MacOS)
|
// Request OpenGL 4.1 Core (Max available on MacOS)
|
||||||
// MacOS gets mad if we don't explicitly demand a core profile
|
// 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);
|
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<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
if (!gladLoadGL(reinterpret_cast<GLADloadfunc>(SDL_GL_GetProcAddress))) {
|
||||||
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
Helpers::panic("OpenGL init failed: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER)) {
|
if (SDL_WasInit(SDL_INIT_GAMECONTROLLER)) {
|
||||||
gameController = SDL_GameControllerOpen(0);
|
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
|
// Reset our graphics context and initialize the GPU's graphics context
|
||||||
void Emulator::initGraphicsContext() {
|
void Emulator::initGraphicsContext() {
|
||||||
|
#if ENABLE_OPENGL
|
||||||
gl.reset(); // TODO (For when we have multiple backends): Only do this if we are using OpenGL
|
gl.reset(); // TODO (For when we have multiple backends): Only do this if we are using OpenGL
|
||||||
|
#endif
|
||||||
gpu.initGraphicsContext();
|
gpu.initGraphicsContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
#ifdef PANDA3DS_ENABLE_HTTP_SERVER
|
||||||
void Emulator::pollHttpServer() {
|
void Emulator::pollHttpServer() {
|
||||||
std::scoped_lock lock(httpServer.actionMutex);
|
std::scoped_lock lock(httpServer.actionMutex);
|
||||||
|
|
||||||
ServiceManager& srv = kernel.getServiceManager();
|
ServiceManager& srv = kernel.getServiceManager();
|
||||||
|
|
||||||
if (httpServer.pendingAction) {
|
if (httpServer.pendingAction) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue