QAbstractOpenGLFunctions类是一系列类的基类,它们公开每个OpenGL版本和配置文件的所有函数。
头文件:#include
qmake:QT += gui
开始引入:Qt5.1
被继承:QOpenGLFunctions_1_0, QOpenGLFunctions_1_1, QOpenGLFunctions_1_2, QOpenGLFunctions_1_3, QOpenGLFunctions_1_4, QOpenGLFunctions_1_5, QOpenGLFunctions_2_0, QOpenGLFunctions_2_1, QOpenGLFunctions_3_0, QOpenGLFunctions_3_1, QOpenGLFunctions_3_2_Compatibility, QOpenGLFunctions_3_2_Core, QOpenGLFunctions_3_3_Compatibility, QOpenGLFunctions_3_3_Core, QOpenGLFunctions_4_0_Compatibility, QOpenGLFunctions_4_0_Core, QOpenGLFunctions_4_1_Compatibility, QOpenGLFunctions_4_1_Core, QOpenGLFunctions_4_2_Compatibility, QOpenGLFunctions_4_2_Core, QOpenGLFunctions_4_3_Compatibility, QOpenGLFunctions_4_3_Core, QOpenGLFunctions_4_4_Compatibility, QOpenGLFunctions_4_4_Core, QOpenGLFunctions_4_5_Compatibility, QOpenGLFunctions_4_5_Core, and QOpenGLFunctions_ES2
不同平台上的OpenGL实现能够链接到可变数量的OpenGL函数,具体取决于该平台上的OpenGL ABI。 例如,在Microsoft Windows上,只有OpenGL 1.1中的功能可以在构建时链接到。 必须在运行时解析所有其他函数。 传统的解决方案是使用QOpenGLContext :: getProcAddress()或QOpenGLFunctions。 前者繁琐且容易出错,意味着直接处理函数指针。 后者仅暴露了OpenGL ES 2和桌面OpenGL常用的功能。 然而,在编写真实世界的OpenGL应用程序时,有许多新的OpenGL功能非常有用。
Qt现在提供了一系列类,它们都继承自QAbstractOpenGLFunctions,它们通过相应的成员函数公开每个核心OpenGL函数。 每个有效的OpenGL版本和配置文件组合都有一个类。 每个类遵循命名约定: