set depth buffer size to 24 from 16

replace QT OpenGL module by QT GUI
Remove legacy QGL classes
bump default opengl version to 4.5 from 4.1
This commit is contained in:
T1ti
2024-04-30 21:22:00 +02:00
parent ec855558a7
commit 172438e469
6 changed files with 35 additions and 17 deletions

View File

@@ -110,7 +110,7 @@ set(FASTNOISE2_NOISETOOL OFF CACHE BOOL "")
FIND_PACKAGE(FastNoise2 REQUIRED)
FIND_PACKAGE(Sol2 REQUIRED)
FIND_PACKAGE(Qt5 COMPONENTS Widgets OpenGL OpenGLExtensions Network Xml Multimedia REQUIRED)
FIND_PACKAGE(Qt5 COMPONENTS Widgets OpenGLExtensions Gui Network Xml Multimedia REQUIRED)
IF(USE_SQL)
FIND_LIBRARY(MYSQL_LIBRARY NAMES libmysql
@@ -336,8 +336,8 @@ TARGET_LINK_LIBRARIES (noggit
${OPENGL_LIBRARIES}
StormLib
CascLib
Qt5::Gui
Qt5::Widgets
Qt5::OpenGL
Qt5::OpenGLExtensions
Qt5::Xml
Qt5::Network

View File

@@ -13,7 +13,6 @@
#include <QtGui/QOffscreenSurface>
#include <QtGui/QOpenGLFramebufferObjectFormat>
#include <QtOpenGL/QGLPixelBuffer>
#include <optional>
#include <map>
#include <unordered_map>

View File

@@ -39,6 +39,7 @@ int main(int argc, char *argv[])
std::set_terminate(Noggit::Application::NoggitApplication::terminationHandler);
QApplication::setStyle(QStyleFactory::create("Fusion"));
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication q_application (argc, argv);
q_application.setApplicationName ("Noggit");

View File

@@ -14,7 +14,7 @@ namespace Noggit::Application {
noggitApplicationConfiguration.GraphicsConfiguration = NoggitApplicationGraphicsConfiguration();
noggitApplicationConfiguration.GraphicsConfiguration.SwapChainDepth = QSurfaceFormat::TripleBuffer;
noggitApplicationConfiguration.GraphicsConfiguration.DepthBufferSize = 16;
noggitApplicationConfiguration.GraphicsConfiguration.DepthBufferSize = 24;
noggitApplicationConfiguration.GraphicsConfiguration.SwapChainInternal = 0;
noggitApplicationConfiguration.GraphicsConfiguration.SamplesCount = 0;

View File

@@ -70,7 +70,7 @@ namespace Noggit::Application
auto listFilePath = applicationConfiguration.ApplicationListFilePath;
if (!std::filesystem::exists(listFilePath))
{
LogError << "Unable to find listfile! please reinstall Noggit Red, or download from wow.tools" << std::endl;
// LogError << "Unable to find listfile! please reinstall Noggit Red, or download from wow.tools" << std::endl;
}
Log << "Listfile found! : " << listFilePath << std::endl;
@@ -78,25 +78,23 @@ namespace Noggit::Application
auto databaseDefinitionPath = applicationConfiguration.ApplicationDatabaseDefinitionsPath;
if (!std::filesystem::exists(databaseDefinitionPath))
{
LogError << "Unable to find database definitions! please reinstall Noggit Red, or download from wow.tools" << std::endl;
// LogError << "Unable to find database definitions! please reinstall Noggit Red, or download from wow.tools" << std::endl;
}
Log << "Database Definitions found! : " << databaseDefinitionPath << std::endl;
//Initalise OpenGL Context
if (!QGLFormat::hasOpenGL())
{
throw std::runtime_error(
"Your system does not support OpenGL. Sorry, this application can't run without it.");
}
QSurfaceFormat format;
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setVersion(4, 1);
format.setVersion(4, 5); // will automatically set to the highest version available
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapBehavior(applicationConfiguration.GraphicsConfiguration.SwapChainDepth);
format.setSwapInterval(applicationConfiguration.GraphicsConfiguration.SwapChainInternal);
format.setDepthBufferSize(applicationConfiguration.GraphicsConfiguration.DepthBufferSize);
QSettings app_settings;
bool vsync = app_settings.value("vsync", false).toBool();
format.setSwapInterval(vsync ? 1 : applicationConfiguration.GraphicsConfiguration.SwapChainInternal);
// TODO. old config files used 16 so just ignore them, could implement a version check of the config file to update it
format.setDepthBufferSize(24); // applicationConfiguration.GraphicsConfiguration.DepthBufferSize
auto deflt = format.depthBufferSize();
format.setSamples(applicationConfiguration.GraphicsConfiguration.SamplesCount);
QSurfaceFormat::setDefaultFormat(format);
@@ -110,10 +108,31 @@ namespace Noggit::Application
OpenGL::context::scoped_setter const _(::gl, &context);
GLint majVers = 0, minVers = 0;
glGetIntegerv(GL_MAJOR_VERSION, &majVers);
glGetIntegerv(GL_MINOR_VERSION, &minVers);
if (majVers != 4)
{
LogError << "Default GL major version is not 4" << std::endl;
}
else if (minVers < 1) // noggit required 4.1
{
LogError << "Default GL minor version is less than 1" << std::endl;
}
QOpenGLVersionProfile profile = QOpenGLVersionProfile(format);
LogDebug << "GL: Version: " << gl.getString(GL_VERSION) << std::endl;
LogDebug << "GL: Vendor: " << gl.getString(GL_VENDOR) << std::endl;
LogDebug << "GL: Renderer: " << gl.getString(GL_RENDERER) << std::endl;
if (!profile.isValid())
{
LogError << "OpenGL version profile is not valid." << std::endl;
throw std::runtime_error(
"OpenGL version profile is not valid.");
}
_application_configuration = std::make_shared<Noggit::Application::NoggitApplicationConfiguration>(applicationConfiguration);
//All of the below should be Project Initalisation

View File

@@ -17,7 +17,6 @@
#include <string_view>
#include <QtCore/QSettings>
#include <QtGui/QOffscreenSurface>
#include <QtOpenGL/QGLFormat>
#include <QtCore/QDir>
#include <QtWidgets/QApplication>
#include <QtWidgets/QFileDialog>