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

}
相关推荐
电商api24677428107 小时前
解锁淘宝京东拼多多API,让电商数据为你所用
api
qq_4017004111 小时前
Qt Positioning 模块访问设备地理位置信息
开发语言·qt
闫有尽意无琼13 小时前
银河麒麟v11 arm编译Qt creator8.0.2报错
开发语言·qt
lqj_本人13 小时前
鸿蒙Qt触控疑云:事件传递丢失与坐标偏移修复
qt·华为·harmonyos
_OP_CHEN13 小时前
从零开始的Qt开发指南:(五)Qt 常用控件之 QWidget(上):解锁 Qt 界面开发的核心基石
开发语言·c++·qt·前端开发·qwidget·gui开发·qt常用控件
happyjoey21718 小时前
使用Qt自带的Maintenance Tool将Qt6.9升级为QT6.10
开发语言·qt
lqj_本人1 天前
鸿蒙Qt生命周期:后台被杀后的数据自救
qt·华为·harmonyos
爱码小白1 天前
PyQt5 QTimer总结
开发语言·qt
用户268001379191 天前
沃尔玛商品详情 API 返回数据结构化:价格、库存与规格字段映射方案
api