当前位置:网站首页>QT OpenGL rotate, pan, zoom
QT OpenGL rotate, pan, zoom
2022-07-03 12:00:00 【wb175208】
Qt OpenGL Set the rotation 、 translation 、 The zoom . Follow up on the last article :
Qt OpenGL Texture mapping
Modify vertex shaders :
#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;
// Matrix must be initialized , Initialize identity matrix , otherwise GLSL The default matrix in the language is 0 matrix
uniform mat4 trans = mat4(1.0);
void main(){
gl_Position = trans * vec4(aPos.x, aPos.y, aPos.z, 1.0);// In matrix multiplication, it is right times left , Different from the multiplication of explicit reality
outColor = aColor;
textureCoord = aTextureCoord;
}
Modify the code :
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;// The default is the identity matrix
//mat4.scale(1.5); The zoom
//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);
}
rotate 
translation 
The zoom 
aaa
边栏推荐
- Kubernetes 三打探针及探针方式
- STL tutorial 10 container commonalities and usage scenarios
- Cacti监控Redis实现过程
- Redis 笔记 01:入门篇
- 利用Zabbix动态监控磁盘I/O
- VS2015的下载地址和安装教程
- How to convert a numeric string to an integer
- MySQL searches and sorts out common methods according to time
- Excel快速跨表复制粘贴
- Notes on 32-96 questions of sword finger offer
猜你喜欢
随机推荐
vulnhub之cereal
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
Web security summary
Dynamically monitor disk i/o with ZABBIX
【mysql官方文档】死锁
The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
《剑指offer 04》二维数组查找
[learning notes] DP status and transfer
(数据库提权——Redis)Redis未授权访问漏洞总结
R language uses the aggregate function to calculate the mean value (sum) of dataframe data grouping aggregation without setting na The result of RM calculation. If the group contains the missing value
DNS multi-point deployment IP anycast+bgp actual combat analysis
ArcGIS application (XXI) ArcMap method of deleting layer specified features
Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
量化计算调研
vulnhub之raven2
previous permutation lintcode51
shardingSphere分库分表<3>
Unity3D学习笔记5——创建子Mesh
Introduction to the implementation principle of rxjs observable filter operator









