Make Qt work

This commit is contained in:
offtkp 2024-08-08 23:15:53 +03:00
parent 67069a8826
commit a4fcb1c4dc
7 changed files with 61 additions and 20 deletions

View file

@ -173,12 +173,7 @@ void RendererGL::initGraphicsContextInternal() {
defaultShadergenVs.create({defaultShadergenVSSource.c_str(), defaultShadergenVSSource.size()}, OpenGL::Vertex);
}
#ifdef PANDA3DS_FRONTEND_QT
void RendererGL::initGraphicsContext(GL::Context* context)
#elif defined(PANDA3DS_FRONTEND_SDL)
void RendererGL::initGraphicsContext(SDL_Window* context)
#endif
{
void RendererGL::initGraphicsContext(SDL_Window* context) {
if (shaderMode == ShaderMode::Hybrid) {
asyncCompiler = new AsyncCompilerThread(fragShaderGen, context);
}
@ -186,6 +181,16 @@ void RendererGL::initGraphicsContextInternal() {
initGraphicsContextInternal();
}
#ifdef PANDA3DS_FRONTEND_QT
void RendererGL::initGraphicsContext(GL::Context* context) {
if (shaderMode == ShaderMode::Hybrid) {
asyncCompiler = new AsyncCompilerThread(fragShaderGen, context);
}
initGraphicsContextInternal();
}
#endif
// Set up the OpenGL blending context to match the emulated PICA
void RendererGL::setupBlending() {
// Map of PICA blending equations to OpenGL blending equations. The unused blending equations are equivalent to equation 0 (add)

View file

@ -139,4 +139,17 @@ int AndroidUtils::openDocument(const char* path, const char* perms) {
env->DeleteLocalRef(jmode);
return (int)result;
}
}
namespace AsyncCompiler {
void* createContext(void* mainContext) {
throwException(jniEnv(), "AsyncCompiler not supported on Android, how did you manage to enable this?");
return nullptr;
}
void makeCurrent(void* mainContext, void* context) {
}
void destroyContext(void* context) {
}
}

View file

@ -6,8 +6,10 @@
#include <cmath>
#include <cstdio>
#include <fstream>
#include <memory>
#include "cheats.hpp"
#include "gl/context.h"
#include "input_mappings.hpp"
#include "services/dsp.hpp"
@ -601,3 +603,32 @@ void MainWindow::pollControllers() {
}
}
}
namespace AsyncCompiler {
void* createContext(void* mainContext) {
GL::Context* glContext = static_cast<GL::Context*>(mainContext);
// Unlike the SDL function, this doesn't make it current so we don't
// need to call MakeCurrent on the mainContext
WindowInfo wi = glContext->GetWindowInfo();
wi.type = WindowInfo::Type::Surfaceless;
std::unique_ptr<GL::Context>* newContext = new std::unique_ptr<GL::Context>(glContext->CreateSharedContext(wi));
if (newContext->get() == nullptr) {
Helpers::panic("Failed to create shared GL context");
}
return newContext;
}
void makeCurrent(void* mainContext, void* context) {
std::unique_ptr<GL::Context>* glContext = static_cast<std::unique_ptr<GL::Context>*>(context);
(*glContext)->MakeCurrent();
}
void destroyContext(void* context) {
std::unique_ptr<GL::Context>* glContext = static_cast<std::unique_ptr<GL::Context>*>(context);
delete glContext;
}
}