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

}
相关推荐
小小码农Come on10 分钟前
Qt Creator + MSVC 2022 64bit 配置 Dump 文件生成与分析流程
数据库·qt
载数而行52011 分钟前
QT的五类布局
c++·qt·学习
载数而行52028 分钟前
QT的QString类
c++·qt·学习
爱打代码的小林7 小时前
用 OpenAI API 自动化分类智能手表用户问题示例
运维·自动化·大模型·api·智能手表
( ⩌ - ⩌ )7 小时前
OpenCV实现视频采集
opencv·计算机视觉·opengl
alvin_20058 小时前
python之OpenGL应用(五)变换
python·opengl
IOT-Power9 小时前
自动化设备控制系统 / Qt + 嵌入式设备软件
运维·qt·自动化
IOT-Power12 小时前
QT 事件驱动架构
开发语言·qt·架构
umeelove3514 小时前
使用 Qt 插件和 SQLCipher 实现 SQLite 数据库加密与解密
数据库·qt·sqlite
娇娇yyyyyy15 小时前
QT编程(12): QDragEvent事件
qt·microsoft