Qt OpenGL 3D 编程入门

article/2025/7/6 15:12:48

Qt 提供了强大的 OpenGL 集成功能,使得在 Qt 应用中实现 3D 图形变得更加简单。以下是使用 Qt 进行 OpenGL 3D 编程的基础知识。

1. 环境配置

创建 Qt 项目

  1. 新建 Qt Widgets Application 项目

  2. 在 .pro 文件中添加 OpenGL 模块:

qmake

QT       += core gui opengl

基本 OpenGL 窗口类

Qt 提供了 QOpenGLWidget 作为 OpenGL 渲染的基础组件。

openglwidget.h

#ifndef OPENGLWIDGET_H
#define OPENGLWIDGET_H#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QTime>class OpenGLWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core
{Q_OBJECT
public:explicit OpenGLWidget(QWidget *parent = nullptr);~OpenGLWidget();protected:void initializeGL() override;void resizeGL(int w, int h) override;void paintGL() override;void mousePressEvent(QMouseEvent *event) override;void mouseMoveEvent(QMouseEvent *event) override;void wheelEvent(QWheelEvent *event) override;private:QOpenGLVertexArrayObject vao;QOpenGLBuffer vbo{QOpenGLBuffer::VertexBuffer};QOpenGLBuffer ebo{QOpenGLBuffer::IndexBuffer};QOpenGLShaderProgram shaderProgram;QOpenGLTexture *texture;QTime time;QPoint lastMousePos;float xRot = 0.0f;float yRot = 0.0f;float zRot = 0.0f;float zoom = -5.0f;
};#endif // OPENGLWIDGET_H

2. 基本框架实现

openglwidget.cpp

#include "openglwidget.h"
#include <QDebug>
#include <QMouseEvent>
#include <QImage>OpenGLWidget::OpenGLWidget(QWidget *parent) : QOpenGLWidget(parent)
{setFocusPolicy(Qt::StrongFocus);setMouseTracking(true);time.start();
}OpenGLWidget::~OpenGLWidget()
{makeCurrent();vao.destroy();vbo.destroy();ebo.destroy();delete texture;doneCurrent();
}void OpenGLWidget::initializeGL()
{initializeOpenGLFunctions();glClearColor(0.2f, 0.3f, 0.3f, 1.0f);glEnable(GL_DEPTH_TEST);// 立方体顶点数据 (位置 + 颜色 + 纹理坐标)float scale = 2.0f;float vertices[] = {// 前面-0.5f*scale, -0.5f*scale,  0.5f*scale,  1.0f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  0.0f, 1.0f, 0.0f, 1.0f,  1.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  0.0f, 0.0f, 1.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 1.0f, 0.0f, 1.0f,  0.0f, 1.0f,// 后面-0.5f*scale, -0.5f*scale, -0.5f*scale,  1.0f, 0.0f, 1.0f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale, -0.5f*scale,  0.0f, 1.0f, 1.0f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 1.0f, 1.0f, 1.0f,  0.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  0.5f, 0.5f, 0.5f, 1.0f,  1.0f, 1.0f,// 左面-0.5f*scale, -0.5f*scale, -0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,-0.5f*scale, -0.5f*scale,  0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  1.0f, 0.0f,-0.5f*scale,  0.5f*scale,  0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  0.0f, 1.0f,// 右面0.5f*scale, -0.5f*scale, -0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  0.0f, 1.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  1.0f, 1.0f,// 顶面-0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  1.0f, 0.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  0.0f, 1.0f,// 底面-0.5f*scale, -0.5f*scale,  0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale, -0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale, -0.5f*scale, -0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  0.0f, 1.0f};// 索引数据保持不变unsigned int indices[] = {0, 1, 2, 2, 3, 0,4, 5, 6, 6, 7, 4,8, 9, 10, 10, 11, 8,12, 13, 14, 14, 15, 12,16, 17, 18, 18, 19, 16,20, 21, 22, 22, 23, 20};// 初始化 VAO, VBO 和 EBOvao.create();vbo.create();ebo.create();vao.bind();vbo.bind();vbo.allocate(vertices, sizeof(vertices));ebo.bind();ebo.allocate(indices, sizeof(indices));// 顶点着色器const char *vertexShaderSource = R"(#version 330 corelayout(location = 0) in vec3 aPos;layout(location = 1) in vec4 aColor;layout(location = 2) in vec2 aTexCoord;out vec4 ourColor;out vec2 TexCoord;uniform mat4 model;uniform mat4 view;uniform mat4 projection;void main(){gl_Position = projection * view * model * vec4(aPos, 1.0);ourColor = aColor;TexCoord = aTexCoord;})";// 片段着色器const char *fragmentShaderSource = R"(#version 330 corein vec4 ourColor;in vec2 TexCoord;out vec4 FragColor;uniform sampler2D texture1;void main(){vec4 texColor = texture(texture1, TexCoord);FragColor = texColor * ourColor;})";// 编译着色器shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);if (!shaderProgram.link()) {qDebug() << "Shader Program Link Error:" << shaderProgram.log();return;}shaderProgram.bind();// 设置顶点属性指针shaderProgram.setAttributeBuffer(0, GL_FLOAT, 0, 3, 9 * sizeof(float));shaderProgram.enableAttributeArray(0);shaderProgram.setAttributeBuffer(1, GL_FLOAT, 3 * sizeof(float), 4, 9 * sizeof(float));shaderProgram.enableAttributeArray(1);shaderProgram.setAttributeBuffer(2, GL_FLOAT, 7 * sizeof(float), 2, 9 * sizeof(float));shaderProgram.enableAttributeArray(2);// 加载纹理QImage img(":/textures/test.jpeg");if (img.isNull()) {qDebug() << "Failed to load texture image!";img = QImage(2, 2, QImage::Format_RGB32);img.fill(Qt::red);}texture = new QOpenGLTexture(img.mirrored());texture->setMinificationFilter(QOpenGLTexture::Linear);texture->setMagnificationFilter(QOpenGLTexture::Linear);texture->setWrapMode(QOpenGLTexture::Repeat);shaderProgram.setUniformValue("texture1", 0);vao.release();shaderProgram.release();
}void OpenGLWidget::resizeGL(int w, int h)
{glViewport(0, 0, w, h);
}void OpenGLWidget::paintGL()
{glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);shaderProgram.bind();vao.bind();texture->bind(0);QMatrix4x4 model;QMatrix4x4 view;QMatrix4x4 projection;model.rotate(xRot, 1.0f, 0.0f, 0.0f);model.rotate(yRot, 0.0f, 1.0f, 0.0f);model.rotate(zRot, 0.0f, 0.0f, 1.0f);view.translate(0.0f, 0.0f, zoom);projection.perspective(45.0f, width() / float(height()), 0.1f, 100.0f);shaderProgram.setUniformValue("model", model);shaderProgram.setUniformValue("view", view);shaderProgram.setUniformValue("projection", projection);glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);texture->release();vao.release();shaderProgram.release();zRot += 0.5f;if (zRot > 360.0f) zRot -= 360.0f;//update();
}void OpenGLWidget::mousePressEvent(QMouseEvent *event)
{lastMousePos = event->pos();
}void OpenGLWidget::mouseMoveEvent(QMouseEvent *event)
{if (event->buttons() & Qt::LeftButton) {float dx = event->pos().x() - lastMousePos.x();float dy = event->pos().y() - lastMousePos.y();xRot += dy;yRot += dx;lastMousePos = event->pos();update();}
}void OpenGLWidget::wheelEvent(QWheelEvent *event)
{float delta = event->angleDelta().y() / 120.0f;zoom += delta * 0.5f;zoom = qBound(-10.0f, zoom, -1.0f);update();
}

3. 渲染 3D 立方体

准备顶点数据

  // 立方体顶点数据 (位置 + 颜色 + 纹理坐标)float scale = 2.0f;float vertices[] = {// 前面-0.5f*scale, -0.5f*scale,  0.5f*scale,  1.0f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  0.0f, 1.0f, 0.0f, 1.0f,  1.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  0.0f, 0.0f, 1.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 1.0f, 0.0f, 1.0f,  0.0f, 1.0f,// 后面-0.5f*scale, -0.5f*scale, -0.5f*scale,  1.0f, 0.0f, 1.0f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale, -0.5f*scale,  0.0f, 1.0f, 1.0f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 1.0f, 1.0f, 1.0f,  0.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  0.5f, 0.5f, 0.5f, 1.0f,  1.0f, 1.0f,// 左面-0.5f*scale, -0.5f*scale, -0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,-0.5f*scale, -0.5f*scale,  0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  1.0f, 0.0f,-0.5f*scale,  0.5f*scale,  0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  0.6f, 0.0f, 0.0f, 1.0f,  0.0f, 1.0f,// 右面0.5f*scale, -0.5f*scale, -0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  0.0f, 1.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.2f, 0.2f, 1.0f,  1.0f, 1.0f,// 顶面-0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  0.0f, 0.0f,0.5f*scale,  0.5f*scale,  0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  1.0f, 0.0f,0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  1.0f, 1.0f,-0.5f*scale,  0.5f*scale, -0.5f*scale,  1.0f, 0.1f, 0.1f, 1.0f,  0.0f, 1.0f,// 底面-0.5f*scale, -0.5f*scale,  0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  0.0f, 0.0f,0.5f*scale, -0.5f*scale,  0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  1.0f, 0.0f,0.5f*scale, -0.5f*scale, -0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  1.0f, 1.0f,-0.5f*scale, -0.5f*scale, -0.5f*scale,  0.5f, 0.0f, 0.0f, 1.0f,  0.0f, 1.0f};// 索引数据保持不变unsigned int indices[] = {0, 1, 2, 2, 3, 0,4, 5, 6, 6, 7, 4,8, 9, 10, 10, 11, 8,12, 13, 14, 14, 15, 12,16, 17, 18, 18, 19, 16,20, 21, 22, 22, 23, 20};

初始化 VAO, VBO 和 EBO

    // 初始化 VAO, VBO 和 EBOvao.create();vbo.create();ebo.create();vao.bind();vbo.bind();vbo.allocate(vertices, sizeof(vertices));ebo.bind();ebo.allocate(indices, sizeof(indices));

创建着色器程序

 // 顶点着色器const char *vertexShaderSource = R"(#version 330 corelayout(location = 0) in vec3 aPos;layout(location = 1) in vec4 aColor;layout(location = 2) in vec2 aTexCoord;out vec4 ourColor;out vec2 TexCoord;uniform mat4 model;uniform mat4 view;uniform mat4 projection;void main(){gl_Position = projection * view * model * vec4(aPos, 1.0);ourColor = aColor;TexCoord = aTexCoord;})";// 编译着色器shaderProgram.addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource);
 // 片段着色器const char *fragmentShaderSource = R"(#version 330 corein vec4 ourColor;in vec2 TexCoord;out vec4 FragColor;uniform sampler2D texture1;void main(){vec4 texColor = texture(texture1, TexCoord);FragColor = texColor * ourColor;})";shaderProgram.addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource);

4. 实现 3D 渲染

void OpenGLWidget::paintGL()
{glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);shaderProgram.bind();vao.bind();texture->bind(0);QMatrix4x4 model;QMatrix4x4 view;QMatrix4x4 projection;model.rotate(xRot, 1.0f, 0.0f, 0.0f);model.rotate(yRot, 0.0f, 1.0f, 0.0f);model.rotate(zRot, 0.0f, 0.0f, 1.0f);view.translate(0.0f, 0.0f, zoom);projection.perspective(45.0f, width() / float(height()), 0.1f, 100.0f);shaderProgram.setUniformValue("model", model);shaderProgram.setUniformValue("view", view);shaderProgram.setUniformValue("projection", projection);glDrawElements(GL_TRIANGLES, 36, GL_UNSIGNED_INT, 0);texture->release();vao.release();shaderProgram.release();zRot += 0.5f;if (zRot > 360.0f) zRot -= 360.0f;
}

5. 添加纹理

加载纹理

 // 加载纹理QImage img(":/textures/test.jpeg");if (img.isNull()) {qDebug() << "Failed to load texture image!";img = QImage(2, 2, QImage::Format_RGB32);img.fill(Qt::red);}texture = new QOpenGLTexture(img.mirrored());texture->setMinificationFilter(QOpenGLTexture::Linear);texture->setMagnificationFilter(QOpenGLTexture::Linear);texture->setWrapMode(QOpenGLTexture::Repeat);shaderProgram.setUniformValue("texture1", 0);

更新顶点属性指针

    // 设置顶点属性指针shaderProgram.setAttributeBuffer(0, GL_FLOAT, 0, 3, 9 * sizeof(float));shaderProgram.enableAttributeArray(0);shaderProgram.setAttributeBuffer(1, GL_FLOAT, 3 * sizeof(float), 4, 9 * sizeof(float));shaderProgram.enableAttributeArray(1);shaderProgram.setAttributeBuffer(2, GL_FLOAT, 7 * sizeof(float), 2, 9 * sizeof(float));shaderProgram.enableAttributeArray(2);

完整工程代码:

https://gitee.com/byxdaz/opengl3d-instance

运行效果图:


http://www.hkcw.cn/article/xmBEcrgkvL.shtml

相关文章

山东警方:10岁失联男童在河道溺亡 搜救行动告终

6月2日,山东滕州市公安局发布警情通报。5月31日22时35分许,警方接到孔某某报警,称其10岁的外孙赵某某于当天17时许离家后失联。接警后,公安机关迅速调阅监控、走访群众,并联合当地政府和社会救援力量,使用搜救警犬和无人机持续开展搜寻工作。6月2日15时许,在邻村一河道内…

韩国大选目前选情如何 李在明领跑选战

韩国第21届总统选举定于6月3日举行,主要候选人仍在抓紧最后机会展开竞选活动,争取更多选票。此次大选在前总统尹锡悦被弹劾后举行,共有7名候选人登记参选,但其中两人已宣布退选,最终有5名候选人参加角逐。这5名候选人分别是共同民主党候选人李在明、国民力量党候选人金文洙…

【深度学习新浪潮】以Dify为例的大模型平台的对比分析

我们从核心功能、适用群体、易用性、可扩展性和安全性五个维度展开对比分析: 一、核心功能对比 平台核心功能多模型支持插件与工具链Dify低代码开发、RAG增强、Agent自律执行、企业级安全支持GPT-4/5、Claude、Llama3、Gemini及开源模型(如Qwen-VL-72B),支持混合模型组合可…

【JAVA】注解+元注解+自定义注解(万字详解)

&#x1f4da;博客主页&#xff1a;代码探秘者 ✨专栏&#xff1a;《JavaSe》 其他更新ing… ❤️感谢大家点赞&#x1f44d;&#x1f3fb;收藏⭐评论✍&#x1f3fb;&#xff0c;您的三连就是我持续更新的动力❤️ &#x1f64f;作者水平有限&#xff0c;欢迎各位大佬指点&…

unity随机生成未知符号教程

目录 前言方法1方法2脚本后言示例代码 前言 在某些游戏中&#xff0c;有一些让人感到意味不明的未知符号&#xff0c;例如在游戏《巴别塔圣歌》中&#xff0c;就有这样一些能让人在初次就看不懂的未知符号。 或者在其他时候&#xff0c;这些未知符号如果跟粒子系统结合在一起的…

OpenCV——Mac系统搭建OpenCV的Java环境

这里写目录标题 一、源码编译安装1.1、下载源码包1.2、cmake安装1.3、java配置1.4、测试 二、Maven引入2.1、添加Maven依赖2.2、加载本地库 一、源码编译安装 1.1、下载源码包 官网下载opencv包&#xff1a;https://opencv.org/releases/ 以4.6.0为例&#xff0c;下载解压后&…

从Docker拉取镜像一直失败超时解决办法

项目场景&#xff1a; 在ubuntu中&#xff0c;使用docker拉去镜像时&#xff0c;一直超时&#xff0c;拉去失败。 问题描述 原因分析&#xff1a; 国外服务器网络不好导致。 解决方案&#xff1a; 解决方案1 设置国内源 我这边测试&#xff0c;更改以后仍然失败 阿里云提供…

告别printf!嵌入式系统高效日志记录方案

目录 1、分级控制与动态过滤机制 2、异步处理与零拷贝架构 3、跨平台适配层设计 在嵌入式系统开发领域&#xff0c;日志记录系统如同数字世界的黑匣子&#xff0c;承载着系统运行状态的关键信息。传统的printf调试方式虽简单易用&#xff0c;但在处理复杂系统时暴露出效率低…

复变函数 $w = z^2$ 的映射图像演示

复变函数 w z 2 w z^2 wz2 的映射图像演示 复变函数 w z 2 w z^2 wz2 是一个基本的二次函数&#xff0c;在复平面上具有有趣的映射性质。下面我将介绍这个函数的映射特性&#xff0c;并使用MATLAB进行可视化演示。 映射特性 极坐标表示&#xff1a;若 z r e i θ z …

【Redis】Zset 有序集合

文章目录 常用命令zaddzcardzcountzrange && zrevrangezrangebyscorezpopmax && bzpopmaxzpopmin && zpopmaxzrank && zrevrankzscorezremzremrangebyrankzremrangebyscorezincrby 集合间操作交集 zinterstore并集 zunionstore 内部编码应用场…

【AI论文】视觉语言模型中的自我修正推理

摘要&#xff1a;推理视觉语言模型&#xff08;VLMs&#xff09;在复杂的多模态任务上表现出了良好的性能。 然而&#xff0c;它们仍然面临着重大挑战&#xff1a;它们对推理错误高度敏感&#xff0c;需要大量带注释的数据或精确的验证器&#xff0c;并且难以在特定领域之外进行…

正则表达式在Java中的应用(补充)

正则表达式在Java中的应用 Java通过java.util.regex包提供正则表达式支持&#xff0c;核心类包括Pattern和Matcher。Pattern用于编译正则表达式模式&#xff0c;Matcher用于匹配操作。基本语法遵循标准正则规则&#xff0c;如\d匹配数字&#xff0c;\w匹配单词字符。 Pattern…

C++ 内存泄漏检测器设计

文章目录 1. C中的动态内存分配2. 什么是内存泄漏3. 内存泄漏的代码案例4. 内存泄漏检查器的设计模块1&#xff1a;位置信息捕获&#xff1a;模块2&#xff1a;内存分配跟踪&#xff1a;模块3&#xff1a;内存释放跟踪&#xff1a;模块4&#xff1a;泄漏记录存储&#xff1a;模…

线程安全与线程池

概念&#xff1a;多个线程&#xff0c;同时操作同一个共享资源的时候&#xff0c;可能会出现业务安全问题。 出现线程安全问题的条件&#xff0c;原因&#xff1a;1.存在多个线程在同时执行 2.同时访问一个共享资源 3.存在修改该共享资源 线程同步&#xff1a;是线程安全…

网络安全的学习路线是怎么样的?

我是几乎完全自学的&#xff0c;十年前从双非跨专业考研到中科大软件学院网络安全专业&#xff0c;读研之前&#xff0c;C语言是自学的&#xff0c;数据结构是自学的&#xff0c;计算机网络是自学的&#xff0c;操作系统是自学的&#xff0c;微机原理是自学的。为了让我们能跟上…

每日算法-250602

每日算法学习记录 - 250602 今天学习和复习了两道利用前缀和与哈希表解决的子数组问题&#xff0c;特此记录。 560. 和为 K 的子数组 题目 思路 本题的核心思想是利用 前缀和 与 哈希表 来优化查找过程。 解题过程 题目要求统计和为 k 的子数组个数。 我们首先预处理出一…

Hadoop学习笔记

&#xff08;1&#xff09;Hadoop概述 Hadoop是一个开源的分布式计算和存储框架&#xff0c;用于处理大规模数据集&#xff08;大数据&#xff09;的并行处理。它由Apache基金会开发&#xff0c;核心设计灵感来自Google的MapReduce和Google文件系统&#xff08;GFS&#xff09…

PCIe—TS1/TS2 之Polling.Configuration (二)

前文 在 Polling.Configuration 次状态中&#xff0c;发送⽅停⽌发送 TS1 序列&#xff0c;转⽽发送 TS2 序列&#xff0c;TS2 序列中的链路和通道&#xff08;lane&#xff09;字段仍然使⽤填充字段填充。 该状态中&#xff0c;发送⽅转⽽发送 TS2 的⽬的是通知链路对端的设备…

如何增加 cPanel中的 PHP 最大上传大小?

PHP通过限制文件上传大小来保护服务器性能&#xff0c;但默认限制对于许多现代网页应用来说太低了。当PHP应用程序显示错误信息&#xff0c;要求你增加PHP的最大上传文件大小时&#xff0c;你可能会遇到这个问题。有多种方法可以提高上传限制&#xff0c;包括直接编辑PHP配置文…

linux——文件系统

被打开的文件放到内存中没有被打开的文件放到磁盘 1. 硬件-->磁盘 磁盘的存储基本单位&#xff1a;扇区&#xff08;512字节&#xff09; 512字节写入到磁盘&#xff0c;磁盘如何转动&#xff1a; 磁盘写入的时候是向柱面进行批量写入的 CHS地址&#xff1a;cylind heade…