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

}
相关推荐
崔庆才丨静觅5 小时前
Veo API:0门槛量产商业级视频!2026视频流量密码,创作者/商家必藏
google·api
雒珣9 小时前
Qt简单任务的多线程操作(无需创建类)
开发语言·qt
请叫我啊腻10 小时前
高并发接入GrsAi APi教程!nano banana pro0.09/张!附亚马逊Ai批量生图工具(免费)
api·独立开发者·nanobanana·nanobananapro·纳米香蕉·出海开发·亚马逊电商
qq_4017004110 小时前
QT C++ 好看的连击动画组件
开发语言·c++·qt
天远API11 小时前
拒绝多头借贷:详解天远多头借贷行业风险版API的Python对接与数据清洗
大数据·api
哥只是传说中的小白11 小时前
Nano Banana Pro高并发接入Grsai Api实战!0.09/张无限批量生成(附接入实战+开源工具)
开发语言·数据库·ai作画·开源·aigc·php·api
m0_6356474811 小时前
Qt使用第三方组件库新手教程(一)
开发语言·c++·qt
雒珣11 小时前
控制QT生成目录
开发语言·qt
嘿嘿潶黑黑12 小时前
Linux 安装 Qt
linux·qt
zxy284722530112 小时前
利用C#对接BotSharp本地大模型AI Agent示例(2)
人工智能·c#·api·ai agent·botsharp