当前位置:网站首页>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
边栏推荐
- 836. 合并集合(DAY 63)并查集
- STL教程9-容器元素深拷贝和浅拷贝问题
- Excel快速跨表复制粘贴
- Mysql根据时间搜索常用方法整理
- vulnhub之Nagini
- AOSP ~ NTP (Network Time Protocol)
- The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
- PHP export word method (one MHT)
- Groovy test class and JUnit test
- Solution to the second weekly test of ACM intensive training of Hunan Institute of technology in 2022
猜你喜欢
Php Export word method (One MHT)
Colleagues wrote a responsibility chain model, with countless bugs
Socket TCP for network communication (I)
Ripper of vulnhub
Web security summary
Unity3d learning notes 5 - create sub mesh
牛牛的组队竞赛
外插散点数据
PHP導出word方法(一mht)
STL tutorial 10 container commonalities and usage scenarios
随机推荐
Test classification in openstack
Excel quick cross table copy and paste
MySQL uses the method of updating linked tables with update
Kubernetes 三打探针及探针方式
Oracle advanced (I) realize DMP by expdp impdp command
Cacti monitors redis implementation process
Groovy test class and JUnit test
"Jianzhi offer 04" two-dimensional array search
php 获取文件夹下面的文件列表和文件夹列表
previous permutation lintcode51
mysql使用update联表更新的方法
OpenStack中的测试分类
Vulnhub geminiinc V2
Excel快速跨表复制粘贴
OpenGL 索引缓存对象EBO和线宽模式
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
Ripper of vulnhub
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
rxjs Observable filter Operator 的实现原理介绍
Pragma pack syntax and usage