当前位置:网站首页>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
边栏推荐
- MySQL searches and sorts out common methods according to time
- Concurrent programming - singleton
- MySQL uses the method of updating linked tables with update
- Web安全总结
- 银泰百货点燃城市“夜经济”
- C language AES encryption and decryption
- 2022年中南大学夏令营面试经验
- 《剑指offer 03》数组中重复的数字
- How should intermediate software designers prepare for the soft test
- Repo ~ common commands
猜你喜欢
Based on MCU, how to realize OTA differential upgrade with zero code and no development?
ASP. Net hotel management system
导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....
836. 合并集合(DAY 63)并查集
vulnhub之GeminiInc
Numpy np.max和np.maximum实现relu函数
AOSP ~ NTP ( 网络时间协议 )
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
STL教程10-容器共性和使用场景
DS90UB949
随机推荐
Numpy np. Max and np Maximum implements the relu function
ftp登录时,报错“530 Login incorrect.Login failed”
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
The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
2022年湖南工学院ACM集训第二次周测题解
Keepalived中Master和Backup角色选举策略
vulnhub之narak
R语言使用aggregate函数计算dataframe数据分组聚合的均值(sum)、不设置na.rm计算的结果、如果分组中包含缺失值NA则计算结果也为NA
Event preview | the live broadcast industry "rolled in" to drive new data growth points with product power
Yintai department store ignites the city's "night economy"
鸿蒙第四次培训
一些常用术语
Gut | Yu Jun group of the Chinese University of Hong Kong revealed that smoking changes intestinal flora and promotes colorectal cancer (do not smoke)
P3250 [hnoi2016] Network + [necpc2022] f.tree path tree section + segment tree maintenance heap
Visual Studio 2022下载及配置OpenCV4.5.5
MCDF实验1
同事写了一个责任链模式,bug无数...
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
The LINQ expression node type 'ArrayIndex' is not supported in LINQ to Entities
Redis things