From b4a16437d3d8cdcb1bc71c5a4deca5f7a3a0f8b9 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Mon, 26 Apr 2021 02:45:20 +0500 Subject: [PATCH] Add a separate build option for the OpenGL renderer --- CMakeLists.txt | 1 + src/config.c | 4 ++-- src/include/86box/resource.h | 2 +- src/include/86box/win.h | 2 +- src/win/86Box.rc | 4 ++-- src/win/CMakeLists.txt | 8 +++++++- src/win/Makefile.mingw | 14 +++++++++++++- src/win/win.c | 4 ++-- src/win/win_ui.c | 8 ++++---- 9 files changed, 33 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24d3d2463..f66f0c4ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,7 @@ CMAKE_DEPENDENT_OPTION(MGA "Matrox Mystique graphics adapters" ON "DEV_BRANCH" O CMAKE_DEPENDENT_OPTION(NO_SIO "Machines without emulated Super I/O chips" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(OLIVETTI "Olivetti M290" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(OPEN_AT "OpenAT" ON "DEV_BRANCH" OFF) +CMAKE_DEPENDENT_OPTION(OPENGL "OpenGL 3.3 Core renderer" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(PAS16 "Pro Audio Spectrum 16" OFF "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(PS2M70T4 "IBM PS/2 model 70 (type 4)" ON "DEV_BRANCH" OFF) CMAKE_DEPENDENT_OPTION(S3TRIO3D2X "S3 Trio3D/2X" ON "DEV_BRANCH" OFF) diff --git a/src/config.c b/src/config.c index 68f3d306d..4ec3eb5a6 100644 --- a/src/config.c +++ b/src/config.c @@ -529,7 +529,7 @@ load_general(void) enable_discord = !!config_get_int(cat, "enable_discord", 0); #endif -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) video_framerate = config_get_int(cat, "video_gl_framerate", -1); video_vsync = config_get_int(cat, "video_gl_vsync", 0); strcpy_s(video_shader, sizeof(video_shader), config_get_string(cat, "video_gl_shader", "")); @@ -1974,7 +1974,7 @@ save_general(void) config_delete_var(cat, "enable_discord"); #endif -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) if (video_framerate != -1) config_set_int(cat, "video_gl_framerate", video_framerate); else diff --git a/src/include/86box/resource.h b/src/include/86box/resource.h index a3b2a0f93..b5f9a6449 100644 --- a/src/include/86box/resource.h +++ b/src/include/86box/resource.h @@ -341,7 +341,7 @@ #define IDM_DISCORD 40090 #endif -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) #define IDM_VID_GL_FPS_BLITTER 40100 #define IDM_VID_GL_FPS_25 40101 #define IDM_VID_GL_FPS_30 40102 diff --git a/src/include/86box/win.h b/src/include/86box/win.h index 09c318e2f..087387a36 100644 --- a/src/include/86box/win.h +++ b/src/include/86box/win.h @@ -63,7 +63,7 @@ DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); #define ZIP_SUBMENU_NAME L"ZIPSubmenu" #define MO_SUBMENU_NAME L"MOSubmenu" -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) #define VID_GL_SUBMENU L"VidGLSubMenu" #endif diff --git a/src/win/86Box.rc b/src/win/86Box.rc index f9671af32..24df898da 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -66,7 +66,7 @@ BEGIN MENUITEM "&SDL (Software)", IDM_VID_SDL_SW MENUITEM "SDL (&Hardware)", IDM_VID_SDL_HW MENUITEM "SDL (&OpenGL)", IDM_VID_SDL_OPENGL -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) MENUITEM "Open&GL (3.3 Core)", IDM_VID_OPENGL_CORE #endif #ifdef USE_VNC @@ -237,7 +237,7 @@ BEGIN END END -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) VidGLSubMenu MENU DISCARDABLE BEGIN POPUP "Target &framerate" diff --git a/src/win/CMakeLists.txt b/src/win/CMakeLists.txt index cdb52aaae..4ef82f162 100644 --- a/src/win/CMakeLists.txt +++ b/src/win/CMakeLists.txt @@ -20,7 +20,7 @@ add_library(plat OBJECT win.c win_dynld.c win_thread.c win_cdrom.c add_library(ui OBJECT win_ui.c win_stbar.c win_sdl.c win_dialog.c win_about.c win_settings.c win_devconf.c win_snd_gain.c win_specify_dim.c win_new_floppy.c - win_jsconf.c win_media_menu.c 86Box.rc glad.c win_opengl.c win_opengl_glslp.c) + win_jsconf.c win_media_menu.c 86Box.rc) if(MSVC) # MSVC complains when we include the manifest from 86Box.rc... @@ -49,5 +49,11 @@ if(DISCORD) target_sources(ui PRIVATE win_discord.c) endif() +if(OPENGL) + # PUBLIC due to config.c + target_compile_definitions(ui PUBLIC USE_OPENGL) + target_sources(ui PRIVATE glad.c win_opengl.c win_opengl_glslp.c) +endif() + target_link_libraries(86Box advapi32 comctl32 comdlg32 gdi32 shell32 iphlpapi dxguid imm32 hid setupapi uxtheme version winmm psapi) diff --git a/src/win/Makefile.mingw b/src/win/Makefile.mingw index bee34866a..011ac0755 100644 --- a/src/win/Makefile.mingw +++ b/src/win/Makefile.mingw @@ -63,6 +63,9 @@ ifeq ($(DEV_BUILD), y) ifndef OPEN_AT OPEN_AT := y endif + ifndef OPENGL + OPENGL := y + endif ifndef PAS16 PAS16 := n endif @@ -133,6 +136,9 @@ else ifndef OPEN_AT OPEN_AT := n endif + ifndef OPENGL + OPENGL := n + endif ifndef PAS16 PAS16 := n endif @@ -433,7 +439,7 @@ ifeq ($(WX), y) UIOBJ := wx_main.o wx_ui.o wx_stbar.o wx_render.o else UIOBJ := win_ui.o win_stbar.o \ - win_sdl.o win_opengl.o win_opengl_glslp.o glad.o \ + win_sdl.o \ win_dialog.o win_about.o \ win_settings.o win_devconf.o win_snd_gain.o win_specify_dim.o \ win_new_floppy.o win_jsconf.o win_media_menu.o @@ -527,6 +533,12 @@ ifeq ($(OPEN_AT), y) OPTS += -DUSE_OPEN_AT endif +ifeq ($(OPENGL), y) +OPTS += -DUSE_OPENGL +RFLAGS += -DUSE_OPENGL +DEVBROBJ += win_opengl.o win_opengl_glslp.o glad.o +endif + ifeq ($(PAS16), y) OPTS += -DUSE_PAS16 DEVBROBJ += snd_pas16.o diff --git a/src/win/win.c b/src/win/win.c index 5d5fe22fd..3afff8deb 100644 --- a/src/win/win.c +++ b/src/win/win.c @@ -104,7 +104,7 @@ static const struct { { "SDL_Software", 1, (int(*)(void*))sdl_inits, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, NULL }, { "SDL_Hardware", 1, (int(*)(void*))sdl_inith, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, NULL }, { "SDL_OpenGL", 1, (int(*)(void*))sdl_initho, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, NULL } -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) ,{ "OpenGL_Core", 1, (int(*)(void*))opengl_init, opengl_close, opengl_resize, opengl_pause, NULL, opengl_set_fs, opengl_reload} #else ,{ "OpenGL_Core", 1, (int(*)(void*))sdl_initho, sdl_close, NULL, sdl_pause, sdl_enable, sdl_set_fs, NULL } /* fall back to SDL_OpenGL */ @@ -939,7 +939,7 @@ plat_vidapi_name(int api) case 2: name = "sdl_opengl"; break; -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) case 3: name = "opengl_core"; break; diff --git a/src/win/win_ui.c b/src/win/win_ui.c index 0a99d7271..ccf737f94 100644 --- a/src/win/win_ui.c +++ b/src/win/win_ui.c @@ -207,7 +207,7 @@ int delete_submenu(HMENU parent, HMENU target) static void show_render_options_menu() { -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) static int menu_vidapi = -1; static HMENU cur_menu = NULL; @@ -288,7 +288,7 @@ ResetAllMenus(void) CheckMenuItem(menuMain, IDM_VID_SDL_SW, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_HW, MF_UNCHECKED); CheckMenuItem(menuMain, IDM_VID_SDL_OPENGL, MF_UNCHECKED); -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) CheckMenuItem(menuMain, IDM_VID_OPENGL_CORE, MF_UNCHECKED); show_render_options_menu(); #endif @@ -738,7 +738,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_VID_SDL_SW: case IDM_VID_SDL_HW: case IDM_VID_SDL_OPENGL: -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) case IDM_VID_OPENGL_CORE: #endif #ifdef USE_VNC @@ -751,7 +751,7 @@ MainWindowProcedure(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) show_render_options_menu(); break; -#ifdef DEV_BRANCH /* feature-opengl */ +#if defined(DEV_BRANCH) && defined(USE_OPENGL) case IDM_VID_GL_FPS_BLITTER: case IDM_VID_GL_FPS_25: case IDM_VID_GL_FPS_30: