当前位置:网站首页>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
边栏推荐
- Groovy test class and JUnit test
- Socket TCP for network communication (I)
- Go语言实现静态服务器
- 为什么我的mysql容器启动不了呢
- MySQL searches and sorts out common methods according to time
- Colleagues wrote a responsibility chain model, with countless bugs
- 网络通讯之Socket-Tcp(一)
- Oracle advanced (I) realize DMP by expdp impdp command
- Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
- SystemVerilog -- OOP -- copy of object
猜你喜欢
随机推荐
ArcGIS应用(二十一)Arcmap删除图层指定要素的方法
为什么我的mysql容器启动不了呢
R language uses grid of gridextra package The array function combines multiple visual images of the lattice package horizontally, and the ncol parameter defines the number of columns of the combined g
同事写了一个责任链模式,bug无数...
DNS多点部署IP Anycast+BGP实战分析
Differences between MySQL Union and union all
Solve msvcp120d DLL and msvcr120d DLL missing
typeScript
Qt OpenGL 旋转、平移、缩放
Experience container in libvirt
"Jianzhi offer 04" two-dimensional array search
Ripper of vulnhub
外插散点数据
vulnhub之pyexp
STL教程9-容器元素深拷贝和浅拷贝问题
laravel 时区问题timezone
ArcGIS application (XXI) ArcMap method of deleting layer specified features
《剑指offer 04》二维数组查找
pragma-pack语法与使用
DNS multi-point deployment IP anycast+bgp actual combat analysis