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

}
相关推荐
老歌老听老掉牙10 小时前
PyQt5+Qt Designer实战:可视化设计智能参数配置界面,告别手动布局时代!
python·qt
A.A呐12 小时前
【QT第六章】界面优化
开发语言·qt
sycmancia12 小时前
Qt——布局管理器(一)
前端·qt
AlanW13 小时前
QT 信号槽内部实现原理深度解析
qt
A.A呐13 小时前
【QT第五章】系统相关
开发语言·qt
sycmancia13 小时前
Qt——Qt中的标准对话框
开发语言·qt
weixin_4080996719 小时前
【实战教程】EasyClick 调用 OCR 文字识别 API(自动识别屏幕文字 + 完整示例代码)
前端·人工智能·后端·ocr·api·安卓·easyclick
handsomestWei1 天前
Docker引擎API接入配置
运维·http·docker·容器·api
freshman_y1 天前
Qtcreator怎么新建安卓项目?编写一个五子棋游戏APP?
android·qt
weixin_408099671 天前
【完整教程】天诺脚本如何调用 OCR 文字识别 API?自动识别屏幕文字实战(附代码)
前端·人工智能·后端·ocr·api·天诺脚本·自动识别文字脚本