mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-06-28 01:49:42 -06:00
No more context mess (#1531)
* WIP: use Duckstation's context code to directly render into QT Widget from separate thread without two OpenGL contexts currently only works on Windows * reenable gay OSD * add back vsync * make it atleast a little more thread safe * linux support * don't segfault on closing * reorganise and cleanup build system it's still not good, but better than before * macos? * try to get it working on Ubuntu CI also update instructions * let's try this * ok how about this * try creating an OGL 4.3 context first (https://i.kym-cdn.com/photos/images/original/001/264/842/220.png) * fix Ubuntu * hm * try again for Windows * let's try this * make the OpenGL renderer work again that was stupid * do OGL surface resizing from the mainthread * Fix small mistake in GL context creation on macOS causing version 3.2 to be considered invalid * C stupidness * cleanup * don't let the emuthread deinit OGL if there's no OGL * reset lastScreenWidth/Height when deiniting OpenGL * disable stencil test while drawing framebuffers * macOS: Link Cocoa framework explicitly when not building with Qt6 Seems to be needed for the classes used by DuckStation's GL context code. * Set ScreenPanelGL's minimum size immediately Fixes GL context creation for OpenGL display on macOS using the wrong size as the underlying window was not resized to the correct size by Qt yet. * don't emit window updates when OGL display is used * stuff Arisotura said Co-authored-by: Nadia Holmquist Pedersen <nadia@nhp.sh>
This commit is contained in:
@ -45,8 +45,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)
|
||||
@ -71,12 +74,13 @@ set(CMAKE_AUTOMOC ON)
|
||||
set(CMAKE_AUTOUIC ON)
|
||||
set(CMAKE_AUTORCC ON)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
if (BUILD_STATIC)
|
||||
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
|
||||
endif()
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(SDL2 REQUIRED IMPORTED_TARGET sdl2)
|
||||
pkg_check_modules(Slirp REQUIRED IMPORTED_TARGET slirp)
|
||||
pkg_check_modules(LibArchive REQUIRED IMPORTED_TARGET libarchive)
|
||||
@ -87,6 +91,47 @@ add_compile_definitions(ARCHIVE_SUPPORT_ENABLED)
|
||||
|
||||
add_executable(melonDS ${SOURCES_QT_SDL})
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(melonDS PUBLIC opengl32)
|
||||
|
||||
target_sources(melonDS PRIVATE
|
||||
../duckstation/gl/context_wgl.cpp
|
||||
|
||||
../glad/glad_wgl.c
|
||||
)
|
||||
elseif (APPLE)
|
||||
if (NOT USE_QT6)
|
||||
find_library(COCOA_LIB Cocoa)
|
||||
target_link_libraries(melonDS PRIVATE ${COCOA_LIB})
|
||||
endif()
|
||||
target_sources(melonDS PRIVATE
|
||||
../duckstation/gl/context_agl.mm
|
||||
)
|
||||
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)
|
||||
@ -95,6 +140,11 @@ endif()
|
||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..")
|
||||
target_include_directories(melonDS PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../..")
|
||||
if (USE_QT6)
|
||||
target_include_directories(melonDS PUBLIC ${Qt6Gui_PRIVATE_INCLUDE_DIRS})
|
||||
else()
|
||||
target_include_directories(melonDS PUBLIC ${Qt5Gui_PRIVATE_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_link_libraries(melonDS PRIVATE core)
|
||||
target_link_libraries(melonDS PRIVATE PkgConfig::SDL2 PkgConfig::Slirp PkgConfig::LibArchive)
|
||||
target_link_libraries(melonDS PRIVATE ${QT_LINK_LIBS} ${CMAKE_DL_LIBS})
|
||||
|
Reference in New Issue
Block a user