diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 25eb7846b4..be53b71393 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -323,7 +323,10 @@ if (ENABLE_OPENGL) endif() target_link_libraries(video_core PUBLIC common core) -target_link_libraries(video_core PUBLIC glad shader_recompiler stb bc_decoder gpu_logging) +target_link_libraries(video_core PUBLIC shader_recompiler stb bc_decoder gpu_logging) +if (ENABLE_OPENGL) + target_link_libraries(video_core PUBLIC glad) +endif() if (YUZU_USE_EXTERNAL_FFMPEG) add_dependencies(video_core ffmpeg-build) diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 3adce1dd8b..ff0312660b 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt @@ -411,8 +411,11 @@ endif() target_link_libraries(yuzu PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(yuzu PRIVATE common core input_common frontend_common network video_core qt_common) -target_link_libraries(yuzu PRIVATE Boost::headers glad Qt6::Widgets Qt6::Charts Qt6::Concurrent) +target_link_libraries(yuzu PRIVATE Boost::headers Qt6::Widgets Qt6::Charts Qt6::Concurrent) target_link_libraries(yuzu PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) +if (ENABLE_OPENGL) + target_link_libraries(yuzu PRIVATE glad) +endif() if (UNIX AND NOT APPLE) target_link_libraries(yuzu PRIVATE Qt6::DBus) diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 0c0ce6e90c..f7adb1b693 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -8,7 +8,10 @@ #include #include #include + +#ifdef HAS_OPENGL #include +#endif #include #include "common/settings_enums.h" @@ -1039,6 +1042,7 @@ void GRenderWindow::InitializeNull() { } bool GRenderWindow::LoadOpenGL() { +#ifdef HAS_OPENGL auto context = CreateSharedContext(); auto scope = context->Acquire(); if (!gladLoadGL()) { @@ -1069,6 +1073,12 @@ bool GRenderWindow::LoadOpenGL() { // Non fatal } return true; +#else + QMessageBox::warning( + this, tr("Error while initializing OpenGL!"), + tr("This build doesn't have OpenGL support.")); + return false; +#endif } QStringList GRenderWindow::GetUnsupportedGLExtensions() const { diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txt index 8f92525ad6..ba2e6c5209 100644 --- a/src/yuzu_cmd/CMakeLists.txt +++ b/src/yuzu_cmd/CMakeLists.txt @@ -15,11 +15,18 @@ function(create_resource file output filename) file(WRITE "${PROJECT_BINARY_DIR}/dist/${output}" "const unsigned char ${filename}[] = {${filedata}};\nconst unsigned ${filename}_size = sizeof(${filename});\n") endfunction() +if (ENABLE_OPENGL) + list(OPENGL_SOURCES APPEND + emu_window/emu_window_sdl2_gl.cpp + emu_window/emu_window_sdl2_gl.h + ) +else() + set(OPENGL_SOURCES "") +endif() + add_executable(yuzu-cmd emu_window/emu_window_sdl2.cpp emu_window/emu_window_sdl2.h - emu_window/emu_window_sdl2_gl.cpp - emu_window/emu_window_sdl2_gl.h emu_window/emu_window_sdl2_null.cpp emu_window/emu_window_sdl2_null.h emu_window/emu_window_sdl2_vk.cpp @@ -28,10 +35,13 @@ add_executable(yuzu-cmd sdl_config.h yuzu.cpp yuzu.rc + ${OPENGL_SOURCES} ) target_link_libraries(yuzu-cmd PRIVATE common core input_common frontend_common video_core) -target_link_libraries(yuzu-cmd PRIVATE glad) +if (ENABLE_OPENGL) + target_link_libraries(yuzu-cmd PRIVATE glad) +endif() if (MSVC) target_link_libraries(yuzu-cmd PRIVATE getopt) endif() diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index 8e518d816c..54cc832bf2 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -31,7 +31,9 @@ #include "sdl_config.h" #include "video_core/renderer_base.h" #include "yuzu_cmd/emu_window/emu_window_sdl2.h" +#ifdef HAS_OPENGL #include "yuzu_cmd/emu_window/emu_window_sdl2_gl.h" +#endif #include "yuzu_cmd/emu_window/emu_window_sdl2_null.h" #include "yuzu_cmd/emu_window/emu_window_sdl2_vk.h" @@ -349,17 +351,22 @@ int main(int argc, char** argv) { std::unique_ptr emu_window; switch (Settings::values.renderer_backend.GetValue()) { +#ifdef HAS_OPENGL case Settings::RendererBackend::OpenGL_GLSL: case Settings::RendererBackend::OpenGL_GLASM: case Settings::RendererBackend::OpenGL_SPIRV: emu_window = std::make_unique(&input_subsystem, system, fullscreen); break; +#endif case Settings::RendererBackend::Vulkan: emu_window = std::make_unique(&input_subsystem, system, fullscreen); break; case Settings::RendererBackend::Null: emu_window = std::make_unique(&input_subsystem, system, fullscreen); break; + default: + LOG_CRITICAL(Frontend, "Invalid renderer backend"); + return -1; } #ifdef _WIN32