diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ca70ece..297f71d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,13 +101,6 @@ endif() option(BUILD_QT_SDL "Build Qt/SDL frontend" ON) -find_package(ECM REQUIRED NO_MODULE) -list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}") - -find_package(X11 REQUIRED) -find_package(EGL REQUIRED) -find_package(Wayland REQUIRED Client) - add_subdirectory(src) if (BUILD_QT_SDL) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 267a8e94..797f04ba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -114,39 +114,6 @@ if (MATH_LIBRARY) target_link_libraries(core PRIVATE ${MATH_LIBRARY}) endif() -if (ENABLE_OGLRENDERER) - target_sources(core PRIVATE - glad/glad.c - - duckstation/gl/context.cpp) - - if (WIN32) - target_link_libraries(core PUBLIC opengl32) - - target_sources(core PRIVATE - # the context stuff would probably be better in the frontend? - duckstation/gl/context_wgl.cpp - - glad/glad_wgl.c) - else() - target_sources(core PRIVATE - duckstation/gl/context_egl.cpp - duckstation/gl/context_egl_x11.cpp - duckstation/gl/context_glx.cpp - duckstation/gl/context_egl_wayland.cpp - duckstation/gl/x11_window.cpp - - glad/glad_egl.c - glad/glad_glx.c) - message("${X11_FOUND}") - message("${X11_LIBRARIES}") - target_link_libraries(core PRIVATE "${X11_LIBRARIES}" "${EGL_LIBRARIES}") - target_include_directories(core PRIVATE "${X11_INCLUDE_DIR}") - endif() - - target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED) -endif() - if (ENABLE_JIT) target_compile_definitions(core PUBLIC JIT_ENABLED) @@ -156,6 +123,10 @@ if (ENABLE_JIT) endif() endif() +if (ENABLE_OPENGLRENDERER) + target_compile_definitions(core PUBLIC OGLRENDERER_ENABLED) +endif() + if (WIN32) target_link_libraries(core PRIVATE ole32 comctl32 ws2_32) elseif(NOT APPLE) diff --git a/src/GPU_OpenGL.cpp b/src/GPU_OpenGL.cpp index 79adf7a2..837d2240 100644 --- a/src/GPU_OpenGL.cpp +++ b/src/GPU_OpenGL.cpp @@ -23,6 +23,7 @@ #include "NDS.h" #include "GPU.h" +#include "GPU3D_OpenGL.h" #include "OpenGLSupport.h" #include "GPU_OpenGL_shaders.h" diff --git a/src/OpenGLSupport.h b/src/OpenGLSupport.h index 948949e6..14be01a6 100644 --- a/src/OpenGLSupport.h +++ b/src/OpenGLSupport.h @@ -22,9 +22,8 @@ #include #include -#include "glad/glad.h" - #include "Platform.h" +#include "PlatformOGL.h" namespace OpenGL diff --git a/src/PlatformOGL.h b/src/PlatformOGL.h new file mode 100644 index 00000000..bc047807 --- /dev/null +++ b/src/PlatformOGL.h @@ -0,0 +1,9 @@ +#ifndef PLATFORMOGL_H +#define PLATFORMOGL_H + +// if you don't wanna use glad for your platform +// add your header here! + +#include "frontend/glad/glad.h" + +#endif diff --git a/src/duckstation/duckstation_compat.h b/src/frontend/duckstation/duckstation_compat.h similarity index 100% rename from src/duckstation/duckstation_compat.h rename to src/frontend/duckstation/duckstation_compat.h diff --git a/src/duckstation/gl/context.cpp b/src/frontend/duckstation/gl/context.cpp similarity index 100% rename from src/duckstation/gl/context.cpp rename to src/frontend/duckstation/gl/context.cpp diff --git a/src/duckstation/gl/context.h b/src/frontend/duckstation/gl/context.h similarity index 100% rename from src/duckstation/gl/context.h rename to src/frontend/duckstation/gl/context.h diff --git a/src/duckstation/gl/context_egl.cpp b/src/frontend/duckstation/gl/context_egl.cpp similarity index 100% rename from src/duckstation/gl/context_egl.cpp rename to src/frontend/duckstation/gl/context_egl.cpp diff --git a/src/duckstation/gl/context_egl.h b/src/frontend/duckstation/gl/context_egl.h similarity index 100% rename from src/duckstation/gl/context_egl.h rename to src/frontend/duckstation/gl/context_egl.h diff --git a/src/duckstation/gl/context_egl_wayland.cpp b/src/frontend/duckstation/gl/context_egl_wayland.cpp similarity index 100% rename from src/duckstation/gl/context_egl_wayland.cpp rename to src/frontend/duckstation/gl/context_egl_wayland.cpp diff --git a/src/duckstation/gl/context_egl_wayland.h b/src/frontend/duckstation/gl/context_egl_wayland.h similarity index 100% rename from src/duckstation/gl/context_egl_wayland.h rename to src/frontend/duckstation/gl/context_egl_wayland.h diff --git a/src/duckstation/gl/context_egl_x11.cpp b/src/frontend/duckstation/gl/context_egl_x11.cpp similarity index 100% rename from src/duckstation/gl/context_egl_x11.cpp rename to src/frontend/duckstation/gl/context_egl_x11.cpp diff --git a/src/duckstation/gl/context_egl_x11.h b/src/frontend/duckstation/gl/context_egl_x11.h similarity index 100% rename from src/duckstation/gl/context_egl_x11.h rename to src/frontend/duckstation/gl/context_egl_x11.h diff --git a/src/duckstation/gl/context_glx.cpp b/src/frontend/duckstation/gl/context_glx.cpp similarity index 100% rename from src/duckstation/gl/context_glx.cpp rename to src/frontend/duckstation/gl/context_glx.cpp diff --git a/src/duckstation/gl/context_glx.h b/src/frontend/duckstation/gl/context_glx.h similarity index 100% rename from src/duckstation/gl/context_glx.h rename to src/frontend/duckstation/gl/context_glx.h diff --git a/src/duckstation/gl/context_wgl.cpp b/src/frontend/duckstation/gl/context_wgl.cpp similarity index 100% rename from src/duckstation/gl/context_wgl.cpp rename to src/frontend/duckstation/gl/context_wgl.cpp diff --git a/src/duckstation/gl/context_wgl.h b/src/frontend/duckstation/gl/context_wgl.h similarity index 100% rename from src/duckstation/gl/context_wgl.h rename to src/frontend/duckstation/gl/context_wgl.h diff --git a/src/duckstation/gl/loader.h b/src/frontend/duckstation/gl/loader.h similarity index 100% rename from src/duckstation/gl/loader.h rename to src/frontend/duckstation/gl/loader.h diff --git a/src/duckstation/gl/x11_window.cpp b/src/frontend/duckstation/gl/x11_window.cpp similarity index 100% rename from src/duckstation/gl/x11_window.cpp rename to src/frontend/duckstation/gl/x11_window.cpp diff --git a/src/duckstation/gl/x11_window.h b/src/frontend/duckstation/gl/x11_window.h similarity index 100% rename from src/duckstation/gl/x11_window.h rename to src/frontend/duckstation/gl/x11_window.h diff --git a/src/duckstation/log.h b/src/frontend/duckstation/log.h similarity index 100% rename from src/duckstation/log.h rename to src/frontend/duckstation/log.h diff --git a/src/duckstation/scoped_guard.h b/src/frontend/duckstation/scoped_guard.h similarity index 100% rename from src/duckstation/scoped_guard.h rename to src/frontend/duckstation/scoped_guard.h diff --git a/src/duckstation/window_info.cpp b/src/frontend/duckstation/window_info.cpp similarity index 100% rename from src/duckstation/window_info.cpp rename to src/frontend/duckstation/window_info.cpp diff --git a/src/duckstation/window_info.h b/src/frontend/duckstation/window_info.h similarity index 100% rename from src/duckstation/window_info.h rename to src/frontend/duckstation/window_info.h diff --git a/src/duckstation/windows_headers.h b/src/frontend/duckstation/windows_headers.h similarity index 100% rename from src/duckstation/windows_headers.h rename to src/frontend/duckstation/windows_headers.h diff --git a/src/glad/eglplatform.h b/src/frontend/glad/eglplatform.h similarity index 100% rename from src/glad/eglplatform.h rename to src/frontend/glad/eglplatform.h diff --git a/src/glad/glad.c b/src/frontend/glad/glad.c similarity index 100% rename from src/glad/glad.c rename to src/frontend/glad/glad.c diff --git a/src/glad/glad.h b/src/frontend/glad/glad.h similarity index 100% rename from src/glad/glad.h rename to src/frontend/glad/glad.h diff --git a/src/glad/glad_egl.c b/src/frontend/glad/glad_egl.c similarity index 100% rename from src/glad/glad_egl.c rename to src/frontend/glad/glad_egl.c diff --git a/src/glad/glad_egl.h b/src/frontend/glad/glad_egl.h similarity index 100% rename from src/glad/glad_egl.h rename to src/frontend/glad/glad_egl.h diff --git a/src/glad/glad_glx.c b/src/frontend/glad/glad_glx.c similarity index 100% rename from src/glad/glad_glx.c rename to src/frontend/glad/glad_glx.c diff --git a/src/glad/glad_glx.h b/src/frontend/glad/glad_glx.h similarity index 100% rename from src/glad/glad_glx.h rename to src/frontend/glad/glad_glx.h diff --git a/src/glad/glad_wgl.c b/src/frontend/glad/glad_wgl.c similarity index 100% rename from src/glad/glad_wgl.c rename to src/frontend/glad/glad_wgl.c diff --git a/src/glad/glad_wgl.h b/src/frontend/glad/glad_wgl.h similarity index 100% rename from src/glad/glad_wgl.h rename to src/frontend/glad/glad_wgl.h diff --git a/src/glad/khrplatform.h b/src/frontend/glad/khrplatform.h similarity index 100% rename from src/glad/khrplatform.h rename to src/frontend/glad/khrplatform.h diff --git a/src/frontend/qt_sdl/CMakeLists.txt b/src/frontend/qt_sdl/CMakeLists.txt index 3342aae2..244c5a74 100644 --- a/src/frontend/qt_sdl/CMakeLists.txt +++ b/src/frontend/qt_sdl/CMakeLists.txt @@ -41,8 +41,11 @@ set(SOURCES_QT_SDL ../FrontendUtil.h ../mic_blow.h + ../glad/glad.c + ../duckstation/gl/context.cpp + ${CMAKE_SOURCE_DIR}/res/melon.qrc - ) +) if (APPLE) option(USE_QT6 "Build using Qt 6 instead of 5" ON) @@ -83,6 +86,38 @@ add_compile_definitions(ARCHIVE_SUPPORT_ENABLED) add_executable(melonDS ${SOURCES_QT_SDL}) +if (WIN32) + target_link_libraries(melonDS PUBLIC opengl32) + + target_sources(melonDS PRIVATE + # the context stuff would probably be better in the frontend? + ../duckstation/gl/context_wgl.cpp + + ../glad/glad_wgl.c) +else() + # we only need ECM for Wayland + # so we only require it from here + find_package(ECM REQUIRED NO_MODULE) + list(APPEND CMAKE_MODULE_PATH "${ECM_MODULE_PATH}") + + find_package(X11 REQUIRED) + find_package(EGL REQUIRED) + find_package(Wayland REQUIRED Client) + + target_sources(melonDS PRIVATE + ../duckstation/gl/context_egl.cpp + ../duckstation/gl/context_egl_x11.cpp + ../duckstation/gl/context_glx.cpp + ../duckstation/gl/context_egl_wayland.cpp + ../duckstation/gl/x11_window.cpp + + ../glad/glad_egl.c + ../glad/glad_glx.c) + target_link_libraries(melonDS PRIVATE "${X11_LIBRARIES}" "${EGL_LIBRARIES}") + target_include_directories(melonDS PRIVATE "${X11_INCLUDE_DIR}") +endif() + + if (BUILD_STATIC) qt_import_plugins(melonDS INCLUDE Qt::QSvgPlugin) target_link_options(melonDS PRIVATE -static)