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

}
相关推荐
艾莉丝努力练剑6 小时前
【QT】初识QT:背景介绍
java·运维·数据库·人工智能·qt·安全·gui
崔庆才丨静觅19 小时前
Gemini Chat Completion API 申请及使用
chatgpt·api·gemini
下位子19 小时前
『OpenGL学习滤镜相机』- Day 12: LUT 滤镜(Look-Up Table)
android·opengl
下位子19 小时前
『OpenGL学习滤镜相机』- Day 11: 实时滤镜效果
android·opengl
m0_5027249520 小时前
QT - 系统托盘
开发语言·qt
深蓝海拓21 小时前
PySide6之QListWidget 学习
笔记·python·qt·学习·pyqt
iChochy21 小时前
NVIDIA NIM 开发平台,提供超多免费大模型
ai·api·ichat
Morwit1 天前
Qt CMake 项目中 QML 和资源文件的引入方式
开发语言·c++·qt
追烽少年x1 天前
Qt面试题合集(五)
qt
m0_502724951 天前
QT - 事件过滤
qt