当前位置:网站首页>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
边栏推荐
- MySQL union和union all区别
- vulnhub之Ripper
- Kubernetes three dozen probes and probe mode
- PHP导出word方法(一phpword)
- Visual Studio 2022下载及配置OpenCV4.5.5
- The excel table is transferred to word, and the table does not exceed the edge paper range
- 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
- DNS multi-point deployment IP anycast+bgp actual combat analysis
- Qt OpenGL相机的使用
- OpenGL 索引缓存对象EBO和线宽模式
猜你喜欢
随机推荐
Uniapp implementation Click to load more
抓包整理外篇fiddler———— 会话栏与过滤器[二]
Go language to realize static server
Extrapolated scatter data
Qt+vtk+occt reading iges/step model
STL tutorial 8-map
win10 上PHP artisan storage:link 出现 symlink (): Protocol error的解决办法
Redis 笔记 01:入门篇
AOSP ~ NTP (Network Time Protocol)
Go语言实现静态服务器
Oracle advanced (I) realize DMP by expdp impdp command
Visual Studio 2022下载及配置OpenCV4.5.5
vulnhub之tomato(西红柿)
Vulnhub's cereal
836. 合并集合(DAY 63)并查集
R language uses data The table package performs data aggregation statistics, calculates window statistics, calculates the median of sliding groups, and merges the generated statistical data into the o
Ripper of vulnhub
Nestjs configuration service, configuring cookies and sessions
Yintai department store ignites the city's "night economy"
优化接口性能








