当前位置:网站首页>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
边栏推荐
- 安裝electron失敗的解决辦法
- Vulnhub's Tomato (tomato)
- 为什么我的mysql容器启动不了呢
- 【mysql官方文档】死锁
- Vulnhub's presidential
- Is BigDecimal safe to calculate the amount? Look at these five pits~~
- Systemverilog-- OOP--对象的拷贝
- The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
- MySQL union和union all区别
- PHP导出word方法(一phpword)
猜你喜欢

STL Tutorial 9 deep copy and shallow copy of container elements

Why can't my MySQL container start

Kibana - installation and configuration of kibana

After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
![[learning notes] DP status and transfer](/img/5e/59c64d2fe08b89fba2d7e1e6de2761.png)
[learning notes] DP status and transfer

量化计算调研

Qt OpenGL 旋转、平移、缩放

AOSP ~ NTP (Network Time Protocol)

为什么我的mysql容器启动不了呢

Slam mapping and autonomous navigation simulation based on turnlebot3
随机推荐
Solution à la défaillance de l'installation d'Electron
STL tutorial 8-map
Vulnhub's Tomato (tomato)
Vulnhub's cereal
OPenGL 基本知识(根据自己理解整理)
Symlink(): solution to protocol error in PHP artisan storage:link on win10
Simple factory and factory method mode
Extrapolated scatter data
Kubernetes 三打探针及探针方式
R language uses grid of gridextra package The array function combines multiple visual images of the ggplot2 package horizontally, and the ncol parameter defines the number of columns of the combined g
Keepalived中Master和Backup角色选举策略
PHP导出word方法(一phpword)
Yintai department store ignites the city's "night economy"
Kubernetes three dozen probes and probe mode
vulnhub之momentum
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
(数据库提权——Redis)Redis未授权访问漏洞总结
Cacti monitors redis implementation process
SystemVerilog -- OOP -- copy of object
vulnhub之raven2