From 0d4a62af9a908c33d0cab6dfdf97a76042761300 Mon Sep 17 00:00:00 2001 From: Mark <1515135+MarkKoz@users.noreply.github.com> Date: Sat, 7 Oct 2023 11:46:47 -0700 Subject: [PATCH] Update to Qt6 / Mod Organizer 2.5 beta 12 --- .gitignore | 47 ++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 26 +++++++++++++++++------ README.md | 14 ++++++++++++- external/nifly | 2 +- src/CMakeLists.txt | 17 ++++++++------- src/NifWidget.cpp | 6 +++--- src/OpenGLShape.cpp | 8 +++---- src/PreviewNif.cpp | 2 +- src/TextureManager.cpp | 4 ++-- src/preview_nif_en.ts | 4 ++++ 10 files changed, 105 insertions(+), 25 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..016801c --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Precompiled Headers +*.gch +*.pch + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# CMake +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps +cmake-build*/ +build/ diff --git a/CMakeLists.txt b/CMakeLists.txt index a61fa50..25d1082 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,16 +1,30 @@ cmake_minimum_required(VERSION 3.16) -project(preview_nif) -set(project_type plugin) -set(enable_warnings OFF) +set(DEPENDENCIES_DIR C:/Repositories/bethesda/mo2/build/build) + +set(BOOST_ROOT ${DEPENDENCIES_DIR}/boost_1_83_0) +set(QT_ROOT C:/Programs/Qt/6.5.2/msvc2019_64) +set(FMT_ROOT ${DEPENDENCIES_DIR}/fmt-8.1.1) +set(PYTHON_ROOT ${DEPENDENCIES_DIR}/python-3.11.5) +set(CMAKE_INSTALL_PREFIX C:/Repositories/bethesda/mo2/build/install) +set(LOOT_PATH ${DEPENDENCIES_DIR}/libloot-0.22.0-win64) +set(SPDLOG_ROOT ${DEPENDENCIES_DIR}/spdlog-v1.10.0) +set(LIBBSARCH_ROOT ${DEPENDENCIES_DIR}/libbsarch-0.0.9-release-x64) +set(ZLIB_ROOT ${DEPENDENCIES_DIR}/zlib-v1.3) +set(LZ4_ROOT ${DEPENDENCIES_DIR}/lz4-v1.9.4) +set(SEVENZ_ROOT ${DEPENDENCIES_DIR}/7zip-23.01) if(DEFINED DEPENDENCIES_DIR) - include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/project.cmake) + include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/mo2.cmake) else() - include(../cmake_common/project.cmake) + include(${CMAKE_CURRENT_LIST_DIR}/cmake_common/mo2.cmake) endif() + +project(preview_nif) + add_subdirectory(src) set(GLI_TEST_ENABLE OFF CACHE BOOL "Build gli unit tests") add_subdirectory(external/gli) add_subdirectory(external/nifly) -target_link_libraries(${PROJECT_NAME} nifly gli) + +target_link_libraries(${PROJECT_NAME} PRIVATE nifly gli) diff --git a/README.md b/README.md index 126825c..53d12d6 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ # modorganizer-preview_nif -NIF preview plugin for Mod Organizer +NIF preview plugin for Mod Organizer 2 + +For Qt6 builds of MO2 (version 2.5+) + +## How to build +Follow the instructions at https://github.com/modorganizer2/mob. Then, open `CMakeLists.txt` and edit the variables at the top to the correct paths. Finally, build with cmake: + +```shell +mkdir build +cmake -S . -B build +cmake --build build --config Release +cmake --install build --config Release +``` diff --git a/external/nifly b/external/nifly index 5504832..a4f513b 160000 --- a/external/nifly +++ b/external/nifly @@ -1 +1 @@ -Subproject commit 5504832da8009248ff68a9d306973ee1ba61a0a4 +Subproject commit a4f513b1e95fd324a8bd2508208fee654c02f6c4 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 86d062b..0865f4c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,8 +1,11 @@ cmake_minimum_required(VERSION 3.16) -if(DEFINED DEPENDENCIES_DIR) - include(${DEPENDENCIES_DIR}/modorganizer_super/cmake_common/src.cmake) -else() - include(../../cmake_common/src.cmake) -endif() -requires_library(libbsarch) -requires_project(game_features) + +add_library(preview_nif SHARED) +mo2_configure_plugin( + preview_nif + WARNINGS OFF + PRIVATE_DEPENDS + libbsarch + Qt::OpenGLWidgets +) +mo2_install_target(preview_nif) diff --git a/src/NifWidget.cpp b/src/NifWidget.cpp index 4edd2ed..4ec78d5 100644 --- a/src/NifWidget.cpp +++ b/src/NifWidget.cpp @@ -2,9 +2,9 @@ #include "NifExtensions.h" #include -#include #include #include +#include using OpenGLFunctions = QOpenGLFunctions_2_1; NifWidget::NifWidget( @@ -131,7 +131,7 @@ void NifWidget::initializeGL() update(); }); - auto f = QOpenGLContext::currentContext()->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); f->glEnable(GL_DEPTH_TEST); f->glDepthFunc(GL_LEQUAL); @@ -140,7 +140,7 @@ void NifWidget::initializeGL() void NifWidget::paintGL() { - auto f = QOpenGLContext::currentContext()->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); for (auto& shape : m_GLShapes) { diff --git a/src/OpenGLShape.cpp b/src/OpenGLShape.cpp index 9184c21..1cb0bb7 100644 --- a/src/OpenGLShape.cpp +++ b/src/OpenGLShape.cpp @@ -3,6 +3,7 @@ #include #include +#include template inline static QOpenGLBuffer* makeVertexBuffer(const std::vector* data, GLuint attrib) @@ -14,8 +15,7 @@ inline static QOpenGLBuffer* makeVertexBuffer(const std::vector* data, GLuint if (buffer->create() && buffer->bind()) { buffer->allocate(data->data(), data->size() * sizeof(T)); - auto f = QOpenGLContext::currentContext() - ->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); f->glEnableVertexAttribArray(attrib); @@ -39,7 +39,7 @@ OpenGLShape::OpenGLShape( nifly::NiShape* niShape, TextureManager* textureManager) { - auto f = QOpenGLContext::currentContext()->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); auto shader = nifFile->GetShader(niShape); auto& version = nifFile->GetHeader().GetVersion(); @@ -327,7 +327,7 @@ void OpenGLShape::setupShaders(QOpenGLShaderProgram* program) program->setUniformValue("outerReflection", outerReflection); } - auto f = QOpenGLContext::currentContext()->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); for (std::size_t i = 0; i < ATTRIB_COUNT; i++) { if (vertexBuffers[i]) { diff --git a/src/PreviewNif.cpp b/src/PreviewNif.cpp index 6b3a342..c1cb380 100644 --- a/src/PreviewNif.cpp +++ b/src/PreviewNif.cpp @@ -30,7 +30,7 @@ QString PreviewNif::description() const MOBase::VersionInfo PreviewNif::version() const { - return MOBase::VersionInfo(0, 1, 8, 1, MOBase::VersionInfo::RELEASE_BETA); + return MOBase::VersionInfo(0, 2, 0, 0, MOBase::VersionInfo::RELEASE_BETA); } QList PreviewNif::settings() const diff --git a/src/TextureManager.cpp b/src/TextureManager.cpp index 19e0162..96763de 100644 --- a/src/TextureManager.cpp +++ b/src/TextureManager.cpp @@ -4,11 +4,11 @@ #include #include -#include #include #include #include +#include #include #include @@ -181,7 +181,7 @@ QOpenGLTexture* TextureManager::makeTexture(const gli::texture& texture) const gli::gl::format format = GL.translate(texture.format(), texture.swizzles()); GLenum target = GL.translate(texture.target()); - auto f = QOpenGLContext::currentContext()->versionFunctions(); + auto f = QOpenGLVersionFunctionsFactory::get(QOpenGLContext::currentContext()); QOpenGLTexture* glTexture = new QOpenGLTexture(static_cast(target)); glTexture->create(); diff --git a/src/preview_nif_en.ts b/src/preview_nif_en.ts index bc7279e..c095d5d 100644 --- a/src/preview_nif_en.ts +++ b/src/preview_nif_en.ts @@ -4,6 +4,7 @@ NifWidget + OpenGL debug message: %1 @@ -11,10 +12,12 @@ PreviewNif + Failed to load file: %1 + Verts: %1 | Faces: %2 | Shapes: %3 @@ -22,6 +25,7 @@ QObject + Failed to interface with managed game plugin