From 50ec75ff1fc30198cfbcd3514473a174580cd27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=AE=E7=94=9F=E8=8B=A5=E6=A2=A6?= <1070753498@qq.com> Date: Wed, 14 Aug 2024 16:25:31 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=9B=B4=E6=96=B0Qt=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=92=8COpenGL=E7=9D=80=E8=89=B2=E5=99=A8=E4=BB=A3=E7=A0=81]?= =?UTF-8?q?=EF=BC=9A=E5=AF=B9Qt=E7=89=88=E6=9C=AC=E5=92=8COpenGL=E7=9D=80?= =?UTF-8?q?=E8=89=B2=E5=99=A8=E4=BB=A3=E7=A0=81=E8=BF=9B=E8=A1=8C=E4=BA=86?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=92=8C=E6=94=B9=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新`action.yml`文件中Qt的默认版本号从`6.7.0`到`6.7.2` - 调整`cmake/qt.cmake`文件,将Windows和Linux系统下Qt的路径更新为对应新版本`6.7.2` - 优化`openglview.cc`文件,简化了`QMetaObject::invokeMethod`的调用方式 - 更新OpenGL着色器文件`texture.frag`和`texture.vert`,添加GL_ARB_shading_language_420pack扩展支持 - 更新`vcpkg.json`文件,将内置基线从`dee924de74e81388140a53c32a919ecec57d20ab`更改为`fe1cde61e971d53c9687cf9a46308f8f55da19fa` --- .../actions/install-dependencies/action.yml | 2 +- cmake/qt.cmake | 4 ++-- src/gpugraphics/openglview.cc | 18 ++++++------------ src/gpugraphics/shader/texture.frag | 12 +++++++----- src/gpugraphics/shader/texture.vert | 14 ++++++++------ vcpkg.json | 4 ++-- 6 files changed, 26 insertions(+), 28 deletions(-) diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index 3c8be4e..d452abe 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -18,7 +18,7 @@ inputs: qt_ver: description: 'qt version' required: false - default: '6.7.0' + default: '6.7.2' type: string runs: diff --git a/cmake/qt.cmake b/cmake/qt.cmake index 5a7f536..56163b4 100644 --- a/cmake/qt.cmake +++ b/cmake/qt.cmake @@ -1,7 +1,7 @@ if(CMAKE_HOST_WIN32) - list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.7.0\\msvc2019_64") + list(APPEND CMAKE_PREFIX_PATH "C:\\Qt\\6.7.2\\msvc2019_64") elseif(CMAKE_HOST_APPLE) elseif(CMAKE_HOST_LINUX) - list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.0/gcc_64") + list(APPEND CMAKE_PREFIX_PATH "/opt/Qt/6.7.2/gcc_64") endif() diff --git a/src/gpugraphics/openglview.cc b/src/gpugraphics/openglview.cc index 1ad7550..9f682e3 100644 --- a/src/gpugraphics/openglview.cc +++ b/src/gpugraphics/openglview.cc @@ -87,8 +87,7 @@ void OpenglView::resetToOriginalSize() d_ptr->transform.scale(factor_w, factor_h, 1.0); emit emitScaleFactor(); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::fitToScreen() @@ -105,24 +104,21 @@ void OpenglView::fitToScreen() d_ptr->transform.scale(factor / factor_w, factor / factor_h, 1.0); emit emitScaleFactor(); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::rotateNinetieth() { d_ptr->transform.rotate(90, 0, 0, 1); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::anti_rotateNinetieth() { d_ptr->transform.rotate(-90, 0, 0, 1); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::initializeGL() @@ -161,8 +157,7 @@ void OpenglView::resizeGL(int w, int h) } d_ptr->windowSize = QSize(w, h); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::paintGL() @@ -195,8 +190,7 @@ void OpenglView::wheelEvent(QWheelEvent *event) d_ptr->transform.scale(factor, factor, 1.0); emit emitScaleFactor(); - QMetaObject::invokeMethod( - this, [this] { update(); }, Qt::QueuedConnection); + QMetaObject::invokeMethod(this, [this] { update(); }, Qt::QueuedConnection); } void OpenglView::mouseDoubleClickEvent(QMouseEvent *event) diff --git a/src/gpugraphics/shader/texture.frag b/src/gpugraphics/shader/texture.frag index 67afff0..45fb906 100644 --- a/src/gpugraphics/shader/texture.frag +++ b/src/gpugraphics/shader/texture.frag @@ -1,10 +1,12 @@ -#version 330 core +#version 330 +#ifdef GL_ARB_shading_language_420pack +#extension GL_ARB_shading_language_420pack : require +#endif -uniform sampler2D tex; // 纹理 +uniform sampler2D tex; -in vec2 TexCord; // 纹理坐标 - -out vec4 FragColor; // 输出颜色 +layout(location = 0) out vec4 FragColor; +in vec2 TexCord; void main() { diff --git a/src/gpugraphics/shader/texture.vert b/src/gpugraphics/shader/texture.vert index ebf053a..99c3083 100644 --- a/src/gpugraphics/shader/texture.vert +++ b/src/gpugraphics/shader/texture.vert @@ -1,14 +1,16 @@ -#version 330 core +#version 330 +#ifdef GL_ARB_shading_language_420pack +#extension GL_ARB_shading_language_420pack : require +#endif uniform mat4 transform; -in vec3 aPos; -in vec2 aTexCord; - -out vec2 TexCord; // 纹理坐标 +out vec2 TexCord; +layout(location = 0) in vec3 aPos; +layout(location = 1) in vec2 aTexCord; void main() { - gl_Position = transform * vec4(aPos, 1.0); TexCord = vec2(aTexCord.x, 1.0 - aTexCord.y); + gl_Position = transform * vec4(aPos, 1.0); } diff --git a/vcpkg.json b/vcpkg.json index 6a21ece..c21b57d 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -8,5 +8,5 @@ "crashpad", "giflib" ], - "builtin-baseline": "dee924de74e81388140a53c32a919ecec57d20ab" -} \ No newline at end of file + "builtin-baseline": "fe1cde61e971d53c9687cf9a46308f8f55da19fa" +}