Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Qt6 / Mod Organizer 2.5 #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
26 changes: 20 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
```
2 changes: 1 addition & 1 deletion external/nifly
Submodule nifly updated 73 files
+4 −1 .gitignore
+20 −0 include/BasicTypes.hpp
+39 −0 include/ExtraData.hpp
+30 −0 include/Geometry.hpp
+9 −0 include/NifFile.hpp
+61 −0 include/Nodes.hpp
+2 −2 include/Object3d.hpp
+209 −57 include/Shaders.hpp
+15 −0 src/ExtraData.cpp
+5 −0 src/Factory.cpp
+52 −1 src/Geometry.cpp
+84 −3 src/NifFile.cpp
+46 −0 src/Nodes.cpp
+4 −4 src/Particles.cpp
+62 −32 src/Shaders.cpp
+11 −4 src/Skin.cpp
+4 −3 tests/CMakeLists.txt
+68 −25 tests/TestNifFile.cpp
+3 −0 tests/TestNifFile.hpp
+190 −0 tests/TestNifFileOptional.cpp
+22 −0 tests/TestUtil.cpp
+3 −0 tests/TestUtil.hpp
+ tests/expected/TestNifFile_Animated_LE.nif
+ tests/expected/TestNifFile_DeepGraph_SE.nif
+ tests/expected/TestNifFile_FO76.nif
+ tests/expected/TestNifFile_FixBSXFlags_AddExtEmit.nif
+ tests/expected/TestNifFile_FixBSXFlags_RemoveExtEmit.nif
+ tests/expected/TestNifFile_FixShaderFlags_AddEnvMap.nif
+ tests/expected/TestNifFile_FixShaderFlags_RemoveEnvMap.nif
+ tests/expected/TestNifFile_Furniture_Col_SE.nif
+ tests/expected/TestNifFile_LooseBlocks_SE.nif
+ tests/expected/TestNifFile_MultiBound_SE.nif
+ tests/expected/TestNifFile_Optimize_Dynamic_LE_to_SE.nif
+ tests/expected/TestNifFile_Optimize_Dynamic_SE_to_LE.nif
+ tests/expected/TestNifFile_Optimize_LE_to_SE.nif
+ tests/expected/TestNifFile_Optimize_SE_to_LE.nif
+ tests/expected/TestNifFile_OrderedNode_SE.nif
+ tests/expected/TestNifFile_RootNonZero.nif
+ tests/expected/TestNifFile_Skinned_Dynamic_SE.nif
+ tests/expected/TestNifFile_Skinned_FO4.nif
+ tests/expected/TestNifFile_Skinned_NoNiSkinDataWeights.nif
+ tests/expected/TestNifFile_Skinned_OB.nif
+ tests/expected/TestNifFile_Skinned_SE.nif
+ tests/expected/TestNifFile_Static_FO4.nif
+ tests/expected/TestNifFile_Static_FO4_132.nif
+ tests/expected/TestNifFile_Static_FO4_139.nif
+ tests/expected/TestNifFile_Static_SE.nif
+ tests/input/TestNifFile_Animated_LE.nif
+ tests/input/TestNifFile_DeepGraph_SE.nif
+ tests/input/TestNifFile_FO76.nif
+ tests/input/TestNifFile_FixBSXFlags_AddExtEmit.nif
+ tests/input/TestNifFile_FixBSXFlags_RemoveExtEmit.nif
+ tests/input/TestNifFile_FixShaderFlags_AddEnvMap.nif
+ tests/input/TestNifFile_FixShaderFlags_RemoveEnvMap.nif
+ tests/input/TestNifFile_Furniture_Col_SE.nif
+ tests/input/TestNifFile_LooseBlocks_SE.nif
+ tests/input/TestNifFile_MultiBound_SE.nif
+ tests/input/TestNifFile_Optimize_Dynamic_LE_to_SE.nif
+ tests/input/TestNifFile_Optimize_Dynamic_SE_to_LE.nif
+ tests/input/TestNifFile_Optimize_LE_to_SE.nif
+ tests/input/TestNifFile_Optimize_SE_to_LE.nif
+ tests/input/TestNifFile_OrderedNode_SE.nif
+ tests/input/TestNifFile_RootNonZero.nif
+ tests/input/TestNifFile_Skinned_Dynamic_SE.nif
+ tests/input/TestNifFile_Skinned_FO4.nif
+ tests/input/TestNifFile_Skinned_NoNiSkinDataWeights.nif
+ tests/input/TestNifFile_Skinned_OB.nif
+ tests/input/TestNifFile_Skinned_SE.nif
+ tests/input/TestNifFile_Static_FO4.nif
+ tests/input/TestNifFile_Static_FO4_132.nif
+ tests/input/TestNifFile_Static_FO4_139.nif
+ tests/input/TestNifFile_Static_SE.nif
+0 −0 tests/output/.gitkeep
17 changes: 10 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 3 additions & 3 deletions src/NifWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include "NifExtensions.h"

#include <QMouseEvent>
#include <QWheelEvent>
#include <QOpenGLContext>
#include <QOpenGLFunctions_2_1>
#include <QOpenGLVersionFunctionsFactory>
using OpenGLFunctions = QOpenGLFunctions_2_1;

NifWidget::NifWidget(
Expand Down Expand Up @@ -131,7 +131,7 @@ void NifWidget::initializeGL()
update();
});

auto f = QOpenGLContext::currentContext()->versionFunctions<OpenGLFunctions>();
auto f = QOpenGLVersionFunctionsFactory::get<OpenGLFunctions>(QOpenGLContext::currentContext());

f->glEnable(GL_DEPTH_TEST);
f->glDepthFunc(GL_LEQUAL);
Expand All @@ -140,7 +140,7 @@ void NifWidget::initializeGL()

void NifWidget::paintGL()
{
auto f = QOpenGLContext::currentContext()->versionFunctions<OpenGLFunctions>();
auto f = QOpenGLVersionFunctionsFactory::get<OpenGLFunctions>(QOpenGLContext::currentContext());
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

for (auto& shape : m_GLShapes) {
Expand Down
8 changes: 4 additions & 4 deletions src/OpenGLShape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QOpenGLContext>
#include <QOpenGLFunctions_2_1>
#include <QOpenGLVersionFunctionsFactory>

template <typename T>
inline static QOpenGLBuffer* makeVertexBuffer(const std::vector<T>* data, GLuint attrib)
Expand All @@ -14,8 +15,7 @@ inline static QOpenGLBuffer* makeVertexBuffer(const std::vector<T>* data, GLuint
if (buffer->create() && buffer->bind()) {
buffer->allocate(data->data(), data->size() * sizeof(T));

auto f = QOpenGLContext::currentContext()
->versionFunctions<QOpenGLFunctions_2_1>();
auto f = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_2_1>(QOpenGLContext::currentContext());

f->glEnableVertexAttribArray(attrib);

Expand All @@ -39,7 +39,7 @@ OpenGLShape::OpenGLShape(
nifly::NiShape* niShape,
TextureManager* textureManager)
{
auto f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
auto f = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_2_1>(QOpenGLContext::currentContext());

auto shader = nifFile->GetShader(niShape);
auto& version = nifFile->GetHeader().GetVersion();
Expand Down Expand Up @@ -327,7 +327,7 @@ void OpenGLShape::setupShaders(QOpenGLShaderProgram* program)
program->setUniformValue("outerReflection", outerReflection);
}

auto f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_2_1>();
auto f = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_2_1>(QOpenGLContext::currentContext());

for (std::size_t i = 0; i < ATTRIB_COUNT; i++) {
if (vertexBuffers[i]) {
Expand Down
2 changes: 1 addition & 1 deletion src/PreviewNif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MOBase::PluginSetting> PreviewNif::settings() const
Expand Down
4 changes: 2 additions & 2 deletions src/TextureManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#include <iplugingame.h>
#include <dataarchives.h>

#include <gli/gli.hpp>
#include <libbsarch.h>

#include <QOpenGLContext>
#include <QOpenGLFunctions_2_1>
#include <QOpenGLVersionFunctionsFactory>
#include <QVector4D>

#include <memory>
Expand Down Expand Up @@ -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<QOpenGLFunctions_2_1>();
auto f = QOpenGLVersionFunctionsFactory::get<QOpenGLFunctions_2_1>(QOpenGLContext::currentContext());
QOpenGLTexture* glTexture = new QOpenGLTexture(static_cast<QOpenGLTexture::Target>(target));

glTexture->create();
Expand Down
4 changes: 4 additions & 0 deletions src/preview_nif_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,28 @@
<context>
<name>NifWidget</name>
<message>
<location filename="NifWidget.cpp" line="91"/>
<source>OpenGL debug message: %1</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PreviewNif</name>
<message>
<location filename="PreviewNif.cpp" line="57"/>
<source>Failed to load file: %1</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="PreviewNif.cpp" line="87"/>
<source>Verts: %1 | Faces: %2 | Shapes: %3</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>
<location filename="TextureManager.cpp" line="117"/>
<source>Failed to interface with managed game plugin</source>
<translation type="unfinished"></translation>
</message>
Expand Down