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

}
相关推荐
用户7783366132116 小时前
写个浏览器插件查 SERP:选中关键词右键看前 10(Chrome MV3 实战)
搜索引擎·api
Junfeng的技术笔记6 小时前
基于 C++/Qt 的雷达回波信号检测与测距仿真系统
qt
Quz6 小时前
QML TableView:自定义样式与排序表格
qt
用户7783366132116 小时前
把地图数据画出来:Leaflet + 搜索 API 做商家分布图
api
Quz6 小时前
QML TableView:可编辑表格与 SQLite 数据持久化
qt·sqlite
Quz6 小时前
QML ListView:C++ 数据模型与 ProxyModel 实时过滤
qt
Quz6 小时前
QML ListView 入门:自定义样式与数据交互
qt
cpp_learner6 小时前
QT 隐藏式密码鉴权:一键开启管理员模式
qt
超兔一体云6 小时前
Vue3组合式API实战——从Options API迁移
api
用户298698530146 小时前
Python 文档格式转换实战:RTF 转 PDF 与 HTML
python·html·api