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

}
相关推荐
落魄Android在线炒饭1 小时前
Android 实战问题反推 OpenGL 概念(上)
android·opengl
小鱼仙官1 小时前
Qt 主界面弹出分界面
开发语言·qt
誰能久伴不乏6 小时前
用 UDP 做一条“可靠“的控制通道
c++·qt·网络协议·udp
Bczheng110 小时前
VS2022 安装MFC和QT
c++·qt·mfc
会编程的小孩10 小时前
8.19号函数
qt
用户298698530141 天前
Python 实现 HTML 转纯文本:两种场景下的文档模型方案
python·html·api
VIP_CQCRE1 天前
Claude Code 如何接入 Ace Data Cloud?终端与 VS Code 配置指南
api·ai编程·vs code·claude code·ace data cloud
蓝祁子yoky1 天前
Qt学习日记 Day15:网络编程(二)- UDP基础
网络·qt·学习
读书札记20221 天前
Qt UTF-8和UTF-8(BOM)
开发语言·qt
ShineWinsu1 天前
对于Qt:QProgressBar常见属性的解析
开发语言·c++·qt·进度条·gui·定时器·qprogressbar