Skip to content

Commit

Permalink
[更新Qt版本和OpenGL着色器代码]:对Qt版本和OpenGL着色器代码进行了更新和改进
Browse files Browse the repository at this point in the history
- 更新`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`
  • Loading branch information
RealChuan committed Aug 14, 2024
1 parent ae0e74f commit 50ec75f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ inputs:
qt_ver:
description: 'qt version'
required: false
default: '6.7.0'
default: '6.7.2'
type: string

runs:
Expand Down
4 changes: 2 additions & 2 deletions cmake/qt.cmake
Original file line number Diff line number Diff line change
@@ -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()
18 changes: 6 additions & 12 deletions src/gpugraphics/openglview.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions src/gpugraphics/shader/texture.frag
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down
14 changes: 8 additions & 6 deletions src/gpugraphics/shader/texture.vert
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 2 additions & 2 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"crashpad",
"giflib"
],
"builtin-baseline": "dee924de74e81388140a53c32a919ecec57d20ab"
}
"builtin-baseline": "fe1cde61e971d53c9687cf9a46308f8f55da19fa"
}

0 comments on commit 50ec75f

Please sign in to comment.