当前位置: 首页 > news >正文

建设网站对企业的重要性企业网站网页设计有哪些

建设网站对企业的重要性,企业网站网页设计有哪些,安卓wap浏览器,临沂公司做网站1. 概述 QOpenGLTexture 是 Qt5 提供的一个类,用于表示和管理 OpenGL 纹理。它封装了 OpenGL 纹理的创建、分配存储、绑定和设置像素数据等操作,简化了 OpenGL 纹理的使用。 2. 重要函数 构造函数: QOpenGLTexture(const QImage &image,…
1. 概述

QOpenGLTexture 是 Qt5 提供的一个类,用于表示和管理 OpenGL 纹理。它封装了 OpenGL 纹理的创建、分配存储、绑定和设置像素数据等操作,简化了 OpenGL 纹理的使用。

2. 重要函数
  • 构造函数

    • QOpenGLTexture(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps)

    • QOpenGLTexture(QOpenGLTexture::Target target)

  • 纹理配置

    • void allocateStorage()

    • void allocateStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType)

    • void setFormat(QOpenGLTexture::TextureFormat format)

    • void setLayers(int layers)

    • void setSize(int width, int height = 1, int depth = 1)

  • 绑定和解绑

    • void bind()

    • void bind(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit)

    • void release()

    • void release(uint unit, QOpenGLTexture::TextureUnitReset reset = DontResetTextureUnit)

  • 设置像素数据

    • void setData(int mipLevel, QOpenGLTexture::PixelFormat sourceFormat, QOpenGLTexture::PixelType sourceType, const void *data, const QOpenGLPixelTransferOptions *const options = nullptr)

    • void setData(const QImage &image, QOpenGLTexture::MipMapGeneration genMipMaps = GenerateMipMaps)

  • 生成 Mipmaps

    • void generateMipMaps()

    • void generateMipMaps(int baseLevel, bool resetBaseLevel = true)

  • 获取纹理属性

    • int width() const

    • int height() const

    • int depth() const

    • GLuint textureId() const

3. 常用枚举类型
  • BindingTarget:纹理绑定目标,如 BindingTarget2DBindingTargetCubeMap 等。

  • ComparisonFunction:深度和模板比较函数。

  • ComparisonMode:比较模式,如 CompareRefToTexture

  • CubeMapFace:立方体贴图的各个面,如 CubeMapPositiveX

  • DepthStencilMode:深度和模板模式。

  • Feature:纹理特性,如 TextureRectangleTextureArrays

  • Filter:纹理过滤方式,如 NearestLinear

  • MipMapGeneration:是否生成 Mipmaps,GenerateMipMapsDontGenerateMipMaps

  • PixelFormat:像素格式,如 RGBA8888

  • PixelType:像素类型,如 UnsignedByte

  • SwizzleComponent:颜色通道,如 SwizzleRed

  • SwizzleValue:颜色值,如 RedValue

  • Target:纹理目标,如 Target2D

  • TextureFormat:纹理格式,如 RGB8_UNorm

  • WrapMode:纹理环绕模式,如 RepeatClampToEdge

#include "widget.h"float vertices[] = {// positions          // colors           // texture coords0.5f,  0.5f, 0.0f,   1.0f, 0.0f, 0.0f,   1.0f, 1.0f, // top right0.5f, -0.5f, 0.0f,   0.0f, 1.0f, 0.0f,   1.0f, 0.0f, // bottom right-0.5f, -0.5f, 0.0f,   0.0f, 0.0f, 1.0f,   0.0f, 0.0f, // bottom left-0.5f,  0.5f, 0.0f,   1.0f, 1.0f, 0.0f,   0.0f, 1.0f  // top left
};
unsigned int indices[] = {0, 1, 3, // first triangle1, 2, 3  // second triangle
};MyGLWidget::MyGLWidget(QWidget *parent) : QOpenGLWidget(parent)
{}MyGLWidget::~MyGLWidget()
{glDeleteVertexArrays(1, &VAO);glDeleteBuffers(1, &VBO);glDeleteBuffers(1, &EBO);
}void MyGLWidget::initializeGL()
{initializeOpenGLFunctions(); // 初始化 OpenGL 函数bool success;m_shaderProgram.addShaderFromSourceFile(QOpenGLShader::Vertex,":/shader/shader.vert");m_shaderProgram.addShaderFromSourceFile(QOpenGLShader::Fragment,":/shader/shader.frag");success=m_shaderProgram.link();if(!success) qDebug()<<"ERR:"<<m_shaderProgram.log();//创建、绑定VAOglGenVertexArrays(1, &VAO);glBindVertexArray(VAO);//创建、绑定VBO + 填充数据glGenBuffers(1, &VBO);glBindBuffer(GL_ARRAY_BUFFER, VBO);glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, EBO);glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);//设置顶点属性指针glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)0);glEnableVertexAttribArray(0);// 颜色属性glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(3* sizeof(float)));glEnableVertexAttribArray(1);//纹理坐标glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 8 * sizeof(float), (void*)(6 * sizeof(float)));glEnableVertexAttribArray(2);//解绑缓冲区和 VAOglBindBuffer(GL_ARRAY_BUFFER, 0);glBindVertexArray(0);//创建、绑定纹理m_diffuseTex = new QOpenGLTexture(QImage(":/img/container.png").mirrored());m_specularTex = new QOpenGLTexture(QImage(":/img/awesomeface.png").mirrored());m_shaderProgram.bind();m_shaderProgram.setUniformValue("texture1", 0);m_shaderProgram.setUniformValue("texture2", 1);;
}void MyGLWidget::paintGL()
{glClearColor(0.2f, 0.3f, 0.3f, 1.0f);glClear(GL_COLOR_BUFFER_BIT); // 清除颜色缓冲区m_shaderProgram.bind();m_diffuseTex->bind(0);m_specularTex->bind(1);glBindVertexArray(VAO);//glDrawArrays(GL_TRIANGLES, 0, 3);glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);glBindVertexArray(0);
}void MyGLWidget::resizeGL(int w, int h)
{glViewport(0, 0, w, h); // 设置视口大小
}unsigned int MyGLWidget::loadTexture(const char *fileName, bool alpha)
{unsigned int texture;glGenTextures(1, &texture); // 生成纹理 IDglBindTexture(GL_TEXTURE_2D, texture); // 绑定纹理// 设置纹理参数glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
#if 0// 加载图片并转换为 OpenGL 格式QImage image;if (!image.load(fileName)){qWarning() << "Failed to load texture image";return 0;}image = QGLWidget::convertToGLFormat(image); // 转换为 OpenGL 格式unsigned char *data = image.bits();// 生成纹理glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, data);glGenerateMipmap(GL_TEXTURE_2D); // 生成多级渐远纹理
#elseQFile file(fileName);file.copy(file.fileName(), QFileInfo(file).fileName());int width, height, nrChannels;stbi_set_flip_vertically_on_load(true); // tell stb_image.h to flip loaded texture's on the y-axis.unsigned char *data = stbi_load(QFileInfo(file).fileName().toStdString().c_str(), &width, &height, &nrChannels, 0);if (data)//awesomeface  container{if(alpha)glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);elseglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, data);glGenerateMipmap(GL_TEXTURE_2D);}else{std::cout << "Failed to load texture1" << std::endl;}stbi_image_free(data);
#endifreturn texture;
}

觉得有帮助的话,打赏一下呗。。

           

需要商务合作(定制程序)的欢迎私信!! 

http://www.dtcms.com/a/422894.html

相关文章:

  • SpringBoot结合Vue 播放 m3u8 格式视频
  • 网站推广目标关键词龙岩网站设计找哪家好
  • 【论文阅读】ASPS: Augmented Segment Anything Model for Polyp Segmentation
  • 精读C++20设计模式——结构型设计模式:享元模式
  • FT8430-LRT非隔离5V100MA电源芯片,满足小家电、智能照明、MCU供电需求,替代阻容降压(典型案例,电路图)
  • [论文阅读]Benchmarking Poisoning Attacks against Retrieval-Augmented Generation
  • 精读C++20设计模式:结构型设计模式:装饰器模式
  • (数据结构)链表OJ——刷题练习
  • 怎么做网站源码温州建网站
  • 云服务器做淘客网站苏州网站制作及推广
  • hive启动报错
  • (基于江协科技)51单片机入门:6.串口
  • UE5 小知识点 —— 09 - 旋转小问题
  • Git 暂存文件警告信息:warning: LF will be replaced by CRLF in XXX.java.
  • 石狮网站建设价格万网网站根目录
  • VBA ADO使用EXCEL 8.0驱动读取 .xlsx 格式表格数据-有限支持
  • freeswitch集成离线语音识别funasr
  • 建设网站管理规定源码做网站图文教程
  • Qt 入门:构建跨平台 GUI 应用的强大框架
  • Spring WebFlux调用生成式AI提供的stream流式接口,实现返回实时对话
  • 【学习笔记】高质量数据集
  • 微美全息科学院(WIMI.US):互信息赋能运动想象脑电分类,脑机接口精度迎来突破!
  • 协议 NTP UDP 获取实时网络时间
  • 公司网站可以分两个域名做吗残疾人网站服务平台
  • spark pipeline 转换n个字段,如何对某个字段反向转换
  • 学习React-18-useCallBack
  • 长沙制作网站的公司与传统市场营销的区别与联系有哪些
  • 从语言到向量:自然语言处理核心转换技术的深度拆解与工程实践导论(自然语言处理入门必读)
  • 无人设备遥控器之无线发射接收技术篇
  • 《从数组到动态顺序表:数据结构与算法如何优化内存管理?》