Deal with renderer magic numbers

This commit is contained in:
Jasmine Iwanek
2025-06-28 18:48:30 -04:00
parent c15f6d757c
commit 9e34464759
4 changed files with 74 additions and 31 deletions

View File

@@ -0,0 +1,40 @@
/*
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
*
* This file is part of the 86Box distribution.
*
* definitions for renderers
*
* Authors: Jasmine Iwanek, <jriwanek@gmail.com>
*
* Copyright 2025 Jasmine Iwanek.
*/
#ifndef EMU_RENDERDEFS_H
#define EMU_RENDERDEFS_H
#define RENDERER_NAME_DEFAULT "default"
#define RENDERER_NAME_SYSTEM "system"
#define RENDERER_NAME_QT_SOFTWARE "qt_software"
#define RENDERER_NAME_QT_OPENGL "qt_opengl"
#define RENDERER_NAME_QT_OPENGLES "qt_opengles"
#define RENDERER_NAME_QT_OPENGL3 "qt_opengl3"
#define RENDERER_NAME_QT_VULKAN "qt_vulkan"
#define RENDERER_NAME_VNC "vnc"
#define RENDERER_SOFTWARE 0
#define RENDERER_OPENGL3 1
#define RENDERER_VULKAN 2
#define RENDERER_VNC 3
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif /*EMU_RENDERDEFS_H*/

View File

@@ -28,6 +28,7 @@
#include <86box/plat.h>
#include <86box/timer.h>
#include <86box/nvr.h>
#include <86box/renderdefs.h>
int
qt_nvr_save(void)
@@ -38,16 +39,16 @@ qt_nvr_save(void)
int
plat_vidapi(const char *api)
{
if (!strcasecmp(api, "default") || !strcasecmp(api, "system"))
return 0;
else if (!strcasecmp(api, "qt_software"))
return 0;
else if (!strcasecmp(api, "qt_opengl") || !strcasecmp(api, "qt_opengles") || !strcasecmp(api, "qt_opengl3"))
return 1;
else if (!strcasecmp(api, "qt_vulkan"))
return 2;
else if (!strcasecmp(api, "vnc"))
return 3;
if (!strcasecmp(api, RENDERER_NAME_DEFAULT) || !strcasecmp(api, RENDERER_NAME_SYSTEM))
return RENDERER_SOFTWARE;
else if (!strcasecmp(api, RENDERER_NAME_QT_SOFTWARE))
return RENDERER_SOFTWARE;
else if (!strcasecmp(api, RENDERER_NAME_QT_OPENGL) || !strcasecmp(api, RENDERER_NAME_QT_OPENGLES) || !strcasecmp(api, RENDERER_NAME_QT_OPENGL3))
return RENDERER_OPENGL3;
else if (!strcasecmp(api, RENDERER_NAME_QT_VULKAN))
return RENDERER_VULKAN;
else if (!strcasecmp(api, RENDERER_NAME_VNC))
return RENDERER_VNC;
return 0;
}
@@ -55,20 +56,20 @@ plat_vidapi(const char *api)
char *
plat_vidapi_name(int api)
{
char *name = "default";
char *name = RENDERER_NAME_DEFAULT;
switch (api) {
case 0:
name = "qt_software";
case RENDERER_SOFTWARE:
name = RENDERER_NAME_QT_SOFTWARE;
break;
case 1:
name = "qt_opengl3";
case RENDERER_OPENGL3:
name = RENDERER_NAME_QT_OPENGL3;
break;
case 2:
name = "qt_vulkan";
case RENDERER_VULKAN:
name = RENDERER_NAME_QT_VULKAN;
break;
case 3:
name = "vnc";
case RENDERER_VNC:
name = RENDERER_NAME_VNC;
break;
default:
fatal("Unknown renderer: %i\n", api);

View File

@@ -55,6 +55,7 @@ extern "C" {
#endif
#include <86box/gdbstub.h>
#include <86box/version.h>
#include <86box/renderdefs.h>
}
#ifdef Q_OS_WINDOWS
@@ -835,7 +836,7 @@ main(int argc, char *argv[])
/* Set the PAUSE mode depending on the renderer. */
#ifdef USE_VNC
if (vid_api == 3)
if (vid_api == RENDERER_VNC)
plat_pause(1);
else
#endif

View File

@@ -52,6 +52,7 @@ extern "C" {
#include <86box/apm.h>
#include <86box/nvr.h>
#include <86box/acpi.h>
#include <86box/renderdefs.h>
#ifdef USE_VNC
# include <86box/vnc.h>
@@ -421,16 +422,16 @@ MainWindow::MainWindow(QWidget *parent)
#endif
if ((QApplication::platformName().contains("eglfs") || QApplication::platformName() == "haiku")) {
if (vid_api >= 1)
if ((vid_api == RENDERER_OPENGL3) || (vid_api == RENDERER_VULKAN))
fprintf(stderr, "OpenGL renderers are unsupported on %s.\n", QApplication::platformName().toUtf8().data());
vid_api = 0;
vid_api = RENDERER_SOFTWARE;
ui->actionVulkan->setVisible(false);
ui->actionOpenGL_3_0_Core->setVisible(false);
}
#ifndef USE_VNC
if (vid_api == 3)
vid_api = 0;
if (vid_api == RENDERER_VNC)
vid_api = RENDERER_SOFTWARE;
ui->actionVNC->setVisible(false);
#endif
@@ -450,8 +451,8 @@ MainWindow::MainWindow(QWidget *parent)
if (!vulkanAvailable)
#endif
{
if (vid_api == 2)
vid_api = 0;
if (vid_api == RENDERER_VULKAN)
vid_api = RENDERER_SOFTWARE;
ui->actionVulkan->setVisible(false);
}
@@ -465,7 +466,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(actGroup, &QActionGroup::triggered, [this](QAction *action) {
vid_api = action->property("vid_api").toInt();
#ifdef USE_VNC
if (vnc_enabled && vid_api != 3) {
if (vnc_enabled && vid_api != RENDERER_VNC) {
startblit();
vnc_enabled = 0;
vnc_close();
@@ -477,17 +478,17 @@ MainWindow::MainWindow(QWidget *parent)
switch (vid_api) {
default:
break;
case 0:
case RENDERER_SOFTWARE:
newVidApi = RendererStack::Renderer::Software;
break;
case 1:
case RENDERER_OPENGL3:
newVidApi = RendererStack::Renderer::OpenGL3;
break;
case 2:
case RENDERER_VULKAN:
newVidApi = RendererStack::Renderer::Vulkan;
break;
#ifdef USE_VNC
case 3:
case RENDERER_VNC:
{
newVidApi = RendererStack::Renderer::Software;
startblit();