mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Add an initial rhi implementation that mimics the opengl implementation
This commit is contained in:
@ -20,8 +20,18 @@ include (../dependencies/pdf_backend.pri)
|
||||
|
||||
INCLUDEPATH += ../common/gl
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
INCLUDEPATH += ../common/rhi
|
||||
DEFINES += YACREADER_USE_RHI
|
||||
}
|
||||
win32 {
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -lopengl32 -luser32
|
||||
LIBS += -loleaut32 -lole32 -lshell32 -luser32
|
||||
# When using RHI (Qt 6.7+), don't link OpenGL directly - QRhiWidget handles graphics APIs
|
||||
message("RHI mode: not linking opengl32 (using QRhiWidget)")
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
} else {
|
||||
LIBS += -lopengl32
|
||||
}
|
||||
|
||||
msvc {
|
||||
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
|
||||
@ -51,6 +61,10 @@ QT += sql network widgets svg quickcontrols2
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5): QT += openglwidgets core5compat
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
QT += gui-private
|
||||
}
|
||||
|
||||
# Input
|
||||
HEADERS += comic_flow.h \
|
||||
../common/concurrent_queue.h \
|
||||
@ -140,6 +154,10 @@ HEADERS += comic_flow.h \
|
||||
|
||||
!CONFIG(no_opengl) {
|
||||
HEADERS += ../common/gl/yacreader_flow_gl.h
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
HEADERS += ../common/rhi/yacreader_flow_rhi.h
|
||||
}
|
||||
}
|
||||
|
||||
SOURCES += comic_flow.cpp \
|
||||
@ -228,6 +246,11 @@ SOURCES += comic_flow.cpp \
|
||||
|
||||
!CONFIG(no_opengl) {
|
||||
SOURCES += ../common/gl/yacreader_flow_gl.cpp
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5):greaterThan(QT_MINOR_VERSION, 6) {
|
||||
SOURCES += ../common/rhi/yacreader_flow_rhi.cpp
|
||||
RESOURCES += ../common/rhi/shaders/shaders.qrc
|
||||
}
|
||||
}
|
||||
|
||||
macx {
|
||||
|
||||
@ -158,10 +158,15 @@ void ComicFlowWidgetSW::resortCovers(QList<int> newOrder)
|
||||
ComicFlowWidgetGL::ComicFlowWidgetGL(QWidget *parent)
|
||||
: ComicFlowWidget(parent)
|
||||
{
|
||||
flow = new YACReaderComicFlowGL(parent);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
qDebug() << "ComicFlowWidgetGL: Creating YACReaderComicFlow3D (RHI implementation)";
|
||||
#else
|
||||
qDebug() << "ComicFlowWidgetGL: Creating YACReaderComicFlowGL (OpenGL implementation)";
|
||||
#endif
|
||||
flow = new YACReaderComicFlowImpl(this);
|
||||
|
||||
connect(flow, &YACReaderFlowGL::centerIndexChanged, this, &ComicFlowWidget::centerIndexChanged);
|
||||
connect(flow, &YACReaderFlowGL::selected, this, &ComicFlowWidget::selected);
|
||||
connect(flow, &YACReaderComicFlowImpl::centerIndexChanged, this, &ComicFlowWidget::centerIndexChanged);
|
||||
connect(flow, &YACReaderComicFlowImpl::selected, this, &ComicFlowWidget::selected);
|
||||
|
||||
auto l = new QVBoxLayout;
|
||||
l->addWidget(flow);
|
||||
|
||||
@ -6,7 +6,14 @@
|
||||
#include "pictureflow.h"
|
||||
#include "comic_flow.h"
|
||||
#ifndef NO_OPENGL
|
||||
// Conditional include based on Qt version and RHI availability
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
#include "yacreader_flow_rhi.h"
|
||||
using YACReaderComicFlowImpl = YACReaderComicFlow3D;
|
||||
#else
|
||||
#include "yacreader_flow_gl.h"
|
||||
using YACReaderComicFlowImpl = YACReaderComicFlowGL;
|
||||
#endif
|
||||
#endif
|
||||
class ComicFlowWidget : public QWidget
|
||||
{
|
||||
@ -83,7 +90,7 @@ class ComicFlowWidgetGL : public ComicFlowWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
YACReaderComicFlowGL *flow;
|
||||
YACReaderComicFlowImpl *flow;
|
||||
|
||||
public:
|
||||
ComicFlowWidgetGL(QWidget *parent = nullptr);
|
||||
|
||||
@ -17,10 +17,10 @@ ComicsView::ComicsView(QWidget *parent)
|
||||
|
||||
view = new QQuickWidget();
|
||||
|
||||
// QQuickWidget requires rendering into OpenGL framebuffer objects
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
view->quickWindow()->setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
#endif
|
||||
// In Qt 6, QQuickWidget supports Qt RHI and can use any graphics backend
|
||||
// (Vulkan, Metal, Direct3D, OpenGL, or software rendering).
|
||||
// The backend can be configured via QQuickWindow::setGraphicsApi() or QSG_RHI_BACKEND env var.
|
||||
// Note: All widgets in the same top-level window must use the same graphics API.
|
||||
|
||||
view->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
connect(
|
||||
|
||||
@ -26,10 +26,10 @@ FolderContentView::FolderContentView(QAction *toogleRecentVisibilityAction, QWid
|
||||
|
||||
view = new QQuickWidget();
|
||||
|
||||
// QQuickWidget requires rendering into OpenGL framebuffer objects
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
view->quickWindow()->setGraphicsApi(QSGRendererInterface::OpenGL);
|
||||
#endif
|
||||
// In Qt 6, QQuickWidget supports Qt RHI and can use any graphics backend
|
||||
// (Vulkan, Metal, Direct3D, OpenGL, or software rendering).
|
||||
// The backend can be configured via QQuickWindow::setGraphicsApi() or QSG_RHI_BACKEND env var.
|
||||
// Note: All widgets in the same top-level window must use the same graphics API.
|
||||
|
||||
view->setResizeMode(QQuickWidget::SizeRootObjectToView);
|
||||
connect(
|
||||
|
||||
@ -204,6 +204,12 @@ void LibraryWindow::setupOpenglSetting()
|
||||
// FLOW-----------------------------------------------------------------------
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
// When using RHI, assume hardware acceleration is available
|
||||
bool openGLAvailable = true;
|
||||
if (!settings->contains(USE_OPEN_GL))
|
||||
settings->setValue(USE_OPEN_GL, 2);
|
||||
#else
|
||||
OpenGLChecker openGLChecker;
|
||||
bool openGLAvailable = openGLChecker.hasCompatibleOpenGLVersion();
|
||||
|
||||
@ -212,6 +218,7 @@ void LibraryWindow::setupOpenglSetting()
|
||||
else if (!openGLAvailable)
|
||||
settings->setValue(USE_OPEN_GL, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void LibraryWindow::setupUI()
|
||||
|
||||
@ -83,8 +83,12 @@ void logSystemAndConfig()
|
||||
else
|
||||
QLOG_INFO() << "OpenGL : disabled";
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) && defined(YACREADER_USE_RHI)
|
||||
QLOG_INFO() << "Using RHI (Qt Rendering Hardware Interface) - graphics backend will be auto-selected";
|
||||
#else
|
||||
OpenGLChecker checker;
|
||||
QLOG_INFO() << "OpenGL version : " << checker.textVersionDescription();
|
||||
#endif
|
||||
|
||||
auto libraries = DBHelper::getLibraries().getLibraries();
|
||||
QLOG_INFO() << "Libraries: ";
|
||||
@ -200,6 +204,8 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
parser.process(app);
|
||||
|
||||
// When using RHI (Qt 6.7+), don't allow OpenGL attribute overrides
|
||||
#if !defined(YACREADER_USE_RHI) || QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||
#ifdef Q_OS_WIN
|
||||
if (parser.isSet("opengl")) {
|
||||
QTextStream qout(stdout);
|
||||
@ -216,6 +222,7 @@ int main(int argc, char **argv)
|
||||
parser.showHelp();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (parser.isSet("loglevel")) {
|
||||
|
||||
Reference in New Issue
Block a user