Skip to content

Commit

Permalink
[更新Qt版本及OpenGL着色器文件]: 更新Qt版本至6.7.2,并修改OpenGL着色器文件的路径和扩展名
Browse files Browse the repository at this point in the history
- 更新了`action.yml`文件中的Qt版本默认值由`6.7.0`至`6.7.2`
- 调整了`cmake/qt.cmake`文件,将Qt的路径从`6.7.0`变更为`6.7.2`,适用于不同操作系统
- 删除并重新创建了OpenGL着色器文件,将`.frag`和`.vert`文件扩展名更改为`.glsl`,并更新了`openglview.cc`中的引用
- 更新了`shader.qrc`文件,以包含新的着色器文件路径
- 移除了旧的着色器文件`texture.frag`和`texture.vert`,并添加了新的着色器文件`texture_frag.glsl`和`texture_vert.glsl`
- 更新了`vcpkg.json`文件,将内置基线从`dee924de74e81388140a53c32a919ecec57d20ab`变更为`fe1cde61e971d53c9687cf9a46308f8f55da19fa`
  • Loading branch information
RealChuan committed Aug 14, 2024
1 parent ae0e74f commit d0998aa
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 47 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()
23 changes: 9 additions & 14 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 All @@ -136,8 +132,9 @@ void OpenglView::initializeGL()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

d_ptr->programPtr.reset(new OpenGLShaderProgram(this));
d_ptr->programPtr->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shader/texture.vert");
d_ptr->programPtr->addShaderFromSourceFile(QOpenGLShader::Fragment, ":/shader/texture.frag");
d_ptr->programPtr->addShaderFromSourceFile(QOpenGLShader::Vertex, ":/shader/texture_vert.glsl");
d_ptr->programPtr->addShaderFromSourceFile(QOpenGLShader::Fragment,
":/shader/texture_frag.glsl");
d_ptr->programPtr->link();
d_ptr->programPtr->bind();

Expand All @@ -161,8 +158,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 +191,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
4 changes: 2 additions & 2 deletions src/gpugraphics/shader.qrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<RCC>
<qresource prefix="/">
<file>shader/texture.frag</file>
<file>shader/texture.vert</file>
<file>shader/texture_frag.glsl</file>
<file>shader/texture_vert.glsl</file>
</qresource>
</RCC>
12 changes: 0 additions & 12 deletions src/gpugraphics/shader/texture.frag

This file was deleted.

14 changes: 0 additions & 14 deletions src/gpugraphics/shader/texture.vert

This file was deleted.

14 changes: 14 additions & 0 deletions src/gpugraphics/shader/texture_frag.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 330
#ifdef GL_ARB_shading_language_420pack
#extension GL_ARB_shading_language_420pack : require
#endif

uniform sampler2D tex;

layout(location = 0) out vec4 FragColor;
in vec2 TexCord;

void main()
{
FragColor = texture(tex, TexCord);
}
16 changes: 16 additions & 0 deletions src/gpugraphics/shader/texture_vert.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#version 330
#ifdef GL_ARB_shading_language_420pack
#extension GL_ARB_shading_language_420pack : require
#endif

uniform mat4 transform;

out vec2 TexCord;
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec2 aTexCord;

void main()
{
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 d0998aa

Please sign in to comment.