当前位置:网站首页>Qt OpenGL 旋转、平移、缩放
Qt OpenGL 旋转、平移、缩放
2022-07-03 11:06:00 【wb175208】
Qt OpenGL 设置旋转、平移、缩放。接上一篇文章:
Qt OpenGL 纹理贴图
修改顶点着色器:
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec3 aColor;
layout (location = 2) in vec2 aTextureCoord;
out vec3 outColor;
out vec2 textureCoord;
//矩阵必须初始化,初始化单位矩阵,否则GLSL语言中默认矩阵是0矩阵
uniform mat4 trans = mat4(1.0);
void main(){
gl_Position = trans * vec4(aPos.x, aPos.y, aPos.z, 1.0);//在矩阵乘法中是右乘左,与显实的乘法不同
outColor = aColor;
textureCoord = aTextureCoord;
}
修改代码:
void TextureWnd::paintGL() {
_openGLCore->glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
_openGLCore->glClear(GL_COLOR_BUFFER_BIT);
_shaderProgram.bind();
_openGLCore->glBindVertexArray(_VAO);
_openGLCore->glActiveTexture(GL_TEXTURE0);
_texture->bind(0);
_openGLCore->glActiveTexture(GL_TEXTURE1);
_texture2->bind(1);
QMatrix4x4 mat4;//默认是单位矩阵
//mat4.scale(1.5);缩放
//mat4.translate(0.3, 0.3, 0.0);
mat4.rotate(45.0f, QVector3D(0.0, 0.0, 1.0));
_shaderProgram.setUniformValue("trans", mat4);
_openGLCore->glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr);
}
旋转
平移
缩放
aaa
边栏推荐
- AOSP ~ NTP ( 网络时间协议 )
- R language ggplot2 visualization: gganimate package creates dynamic line graph animation (GIF) and uses transition_ The reveal function displays data step by step along a given dimension in the animat
- 如何将数字字符串转换为整数
- Unity3D学习笔记5——创建子Mesh
- (database authorization - redis) summary of unauthorized access vulnerabilities in redis
- 金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
- Kibana - installation and configuration of kibana
- STL教程9-容器元素深拷贝和浅拷贝问题
- MySQL union和union all区别
- Cadence background color setting
猜你喜欢
ASP. Net hotel management system
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
Numpy np. Max and np Maximum implements the relu function
How to get started embedded future development direction of embedded
PHP基础
ArcGIS应用(二十一)Arcmap删除图层指定要素的方法
2022年湖南工学院ACM集训第二次周测题解
Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements
vulnhub之presidential
vulnhub之pyexp
随机推荐
(数据库提权——Redis)Redis未授权访问漏洞总结
Groovy test class and JUnit test
GCC compilation process and dynamic link library and static link library
Numpy np.max和np.maximum实现relu函数
小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
vulnhub之Ripper
Some common terms
R language uses data The table package performs data aggregation statistics, calculates window statistics, calculates the median of sliding groups, and merges the generated statistical data into the o
基于turtlebot3实现SLAM建图及自主导航仿真
Nestjs configuration service, configuring cookies and sessions
STL tutorial 10 container commonalities and usage scenarios
How to mix embedded MCU, arm and DSP?
Xiaopeng P7 hit the guardrail and the airbag did not pop up. The official responded that the impact strength did not meet the ejection requirements
《剑指offer 03》数组中重复的数字
The excel table is transferred to word, and the table does not exceed the edge paper range
牛牛的组队竞赛
vulnhub之cereal
Using onvif protocol to operate the device
《剑指offer 04》二维数组查找
Unity3D学习笔记5——创建子Mesh