QT中使用OpenGL function

1.前言

QT做界面编程很方便,QT+OpenGL的使用也很方便,因为QT对原生的OpenGL API进行了面向对象化的封装。

如:

cpp 复制代码
函数:initializeOpenGLFunctions()......
类:QOpenGLVertexArrayObject、QOpenGLBuffer、QOpenGLShaderProgram......
数学工具类:QVector3D、QMatrix4x4......

有些时候我们需要使用原生的OpenGL API,这在QT中也很方便,该怎么做呢?

2.内容

如果想在QT中使用原生的OpenGL API,如**glReadPixels** 、glShaderSource,需要参考QT官方文档说明:

QOpenGLFunctions Class | Qt GUI 6.8.1

继承类QOpenGLExtraFunctions,然后就可以使用上述原生API了,常用的用法是这样的,

cpp 复制代码
#include <QOpenGLWidget>
#include <QOpenGLFunctions_4_5_Core>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QOpenGLBuffer>

//#include <AIS_InteractiveContext.hxx>

class QMenu;
class QRubberBand;

//! Adapted a QWidget for OpenCASCADE viewer.
class OccView : public QOpenGLWidget, QOpenGLFunctions_4_5_Core
{
   // implementation here

}
相关推荐
Bryce学亮19 小时前
FileLine,基于 Qt 6 + QML 构建的跨平台文件传输与即时通讯工具
数据库·c++·人工智能·python·qt·github
VIP_CQCRE1 天前
用 GitHub 做开发者营销:把 Ace Data Cloud 的 API 能力变成可运行项目
ai·github·api·开发者工具·acedatacloud
sycmancia1 天前
Qt——复习篇painter
开发语言·qt
Quz1 天前
QML ProgressBar 基础用法:默认样式与平滑动画
qt
繁重的秋春1 天前
Qt6.0下的CMake的部署配置
qt·cmake
qq_401700411 天前
Qt 程序启动太乱?重新设计你的 Application 生命周期
开发语言·qt
Quz1 天前
QML Tumbler 自定义滚轮:用 PathView 实现横向选择器
qt
万邦科技Lafite2 天前
天猫商品评论API:评价内容中的用户情感倾向分析
人工智能·api·电商开放平台·淘宝开放平台·api开放接口
Quz2 天前
QML Tumbler 样式定制:渐变、高亮与 3D 滚轮效果
qt
隐积2 天前
3.1.7.Qt容器大家族(3):QVariant——万能盒子
开发语言·qt