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

}
相关推荐
高频因子挖掘机1 天前
批量行情返回后,怎样把请求失败的股票单独挑出来?
后端·github·api
高频因子挖掘机1 天前
盘中筛选要同时看价格和盘口?按需分层比“一次全拿”更好维护
后端·github·api
Tanshu_API君1 天前
汇率查询 API :四个子接口与完整使用手册
api·api接口·汇率查询api·实时汇率·汇率换算·汇率转换·外汇实时行情
VIP_CQCRE2 天前
用 Ace Data Cloud 的 gpt-image-2,把 AI 图像生成接入真实业务场景
ai·aigc·api·图像生成·acedatacloud
Quz2 天前
QML PathView:吸附对齐与环形轮播
qt
时间的拾荒人2 天前
Qt 多线程详解:从 QThread 到实战
开发语言·qt·面试
时间的拾荒人2 天前
Qt 事件机制全解析:从事件处理到事件过滤器
开发语言·qt·面试
时间的拾荒人2 天前
Qt 窗口系统详解:从菜单栏到对话框的完整指南
开发语言·qt·面试
qq_401700412 天前
Qt 炫酷曲线,图表,2D/3D开源库
开发语言·qt
扶尔魔ocy2 天前
【qt openGL入门笔记】基础光照
qt·opengl