8#include <QtGui/private/qopenglcontext_p.h>
9#include <QtGui/private/qopengl_p.h>
10#include <QtGui/private/qguiapplication_p.h>
11#include <qpa/qplatformintegration.h>
12#include <qpa/qplatformnativeinterface.h>
18#ifndef GL_FRAMEBUFFER_SRGB_CAPABLE_EXT
19#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
26#define QT_OPENGL_COUNT_FUNCTIONS(ret, name, args) +1
27#define QT_OPENGL_FUNCTION_NAMES(ret, name, args) \
29#define QT_OPENGL_FLAGS(ret, name, args) \
31#define QT_OPENGL_IMPLEMENT(CLASS, FUNCTIONS) \
32void CLASS::init(QOpenGLContext *context) \
34 const char *names = FUNCTIONS(QT_OPENGL_FUNCTION_NAMES); \
35 const char *name = names; \
36 for (int i = 0; i < FUNCTIONS(QT_OPENGL_COUNT_FUNCTIONS); ++i) { \
37 functions[i] = QT_PREPEND_NAMESPACE(getProcAddress(context, name)); \
38 name += strlen(name) + 1; \
192 qWarning(
"QOpenGLFunctions created with non-current context");
215 if ((extensions.
match(
"GL_KHR_blend_equation_advanced")
216 || extensions.
match(
"GL_NV_blend_equation_advanced")) &&
217 (extensions.
match(
"GL_KHR_blend_equation_advanced_coherent")
218 || extensions.
match(
"GL_NV_blend_equation_advanced_coherent"))) {
223 if (
ctx->isOpenGLES()) {
237 if (extensions.
match(
"GL_IMG_texture_npot"))
239 if (extensions.
match(
"GL_OES_texture_npot"))
242 if (
ctx->format().majorVersion() >= 3 || extensions.
match(
"GL_EXT_texture_rg")) {
244 const char *
renderer =
reinterpret_cast<const char *
>(
ctx->functions()->glGetString(GL_RENDERER));
248 if (
ctx->format().majorVersion() >= 3) {
250 if (
ctx->format().minorVersion() >= 2 && extensions.
match(
"GL_KHR_blend_equation_advanced_coherent")) {
261 if (
format.majorVersion() >= 3)
263 else if (extensions.
match(
"GL_EXT_framebuffer_object") || extensions.
match(
"GL_ARB_framebuffer_object"))
266 if (
format.majorVersion() >= 2) {
282 if (extensions.
match(
"GL_ARB_multitexture"))
284 if (extensions.
match(
"GL_ARB_shader_objects"))
286 if (extensions.
match(
"GL_EXT_blend_color"))
288 if (extensions.
match(
"GL_EXT_blend_equation_separate"))
290 if (extensions.
match(
"GL_EXT_blend_subtract"))
292 if (extensions.
match(
"GL_EXT_blend_func_separate"))
294 if (extensions.
match(
"GL_ARB_texture_compression"))
296 if (extensions.
match(
"GL_ARB_multisample"))
298 if (extensions.
match(
"GL_ARB_texture_non_power_of_two"))
306 || (version ==
qMakePair(3, 1) && extensions.
match(
"GL_ARB_compatibility"))
321 if (extensionMatcher.
match(
"GL_EXT_bgra"))
323 if (extensionMatcher.
match(
"GL_ARB_texture_rectangle"))
325 if (extensionMatcher.
match(
"GL_ARB_texture_compression"))
327 if (extensionMatcher.
match(
"GL_EXT_texture_compression_s3tc"))
329 if (extensionMatcher.
match(
"GL_OES_compressed_ETC1_RGB8_texture"))
331 if (extensionMatcher.
match(
"GL_IMG_texture_compression_pvrtc"))
333 if (extensionMatcher.
match(
"GL_KHR_texture_compression_astc_ldr"))
335 if (extensionMatcher.
match(
"GL_ARB_texture_mirrored_repeat"))
337 if (extensionMatcher.
match(
"GL_EXT_stencil_two_side"))
339 if (extensionMatcher.
match(
"GL_EXT_stencil_wrap"))
341 if (extensionMatcher.
match(
"GL_NV_float_buffer"))
343 if (extensionMatcher.
match(
"GL_ARB_pixel_buffer_object"))
345 if (extensionMatcher.
match(
"GL_ARB_texture_swizzle") || extensionMatcher.
match(
"GL_EXT_texture_swizzle"))
347 if (extensionMatcher.
match(
"GL_OES_standard_derivatives"))
349 if (extensionMatcher.
match(
"GL_ARB_half_float_vertex"))
351 if (extensionMatcher.
match(
"GL_OVR_multiview"))
353 if (extensionMatcher.
match(
"GL_OVR_multiview2"))
356 if (
ctx->isOpenGLES()) {
357 if (
format.majorVersion() >= 2)
360 if (
format.majorVersion() >= 3) {
378 if (extensionMatcher.
match(
"GL_OES_packed_depth_stencil"))
380 if (extensionMatcher.
match(
"GL_OES_depth24"))
382 if (extensionMatcher.
match(
"GL_ANGLE_framebuffer_blit"))
384 if (extensionMatcher.
match(
"GL_ANGLE_framebuffer_multisample"))
386 if (extensionMatcher.
match(
"GL_NV_framebuffer_blit"))
388 if (extensionMatcher.
match(
"GL_NV_framebuffer_multisample"))
390 if (extensionMatcher.
match(
"GL_OES_rgb8_rgba8"))
392 if (extensionMatcher.
match(
"GL_OES_compressed_ETC2_RGB8_texture"))
396 if (extensionMatcher.
match(
"GL_OES_mapbuffer"))
398 if (extensionMatcher.
match(
"GL_OES_element_index_uint"))
401 if (extensionMatcher.
match(
"GL_IMG_texture_format_BGRA8888") || extensionMatcher.
match(
"GL_EXT_texture_format_BGRA8888"))
406 static bool wrongfullyReportsBgra8888Support = deviceName != 0
410 if (wrongfullyReportsBgra8888Support)
414 if (extensionMatcher.
match(
"GL_EXT_discard_framebuffer"))
416 if (extensionMatcher.
match(
"GL_EXT_texture_norm16"))
429 if (
format.majorVersion() >= 2)
432 if (
format.majorVersion() >= 3 || extensionMatcher.
match(
"GL_ARB_framebuffer_object")) {
439 if (extensionMatcher.
match(
"GL_EXT_framebuffer_multisample"))
441 if (extensionMatcher.
match(
"GL_EXT_framebuffer_blit"))
443 if (extensionMatcher.
match(
"GL_EXT_packed_depth_stencil"))
453 if (extensionMatcher.
match(
"GL_ARB_map_buffer_range"))
456 if (extensionMatcher.
match(
"GL_EXT_framebuffer_sRGB")) {
457 GLboolean srgbCapableFramebuffers =
false;
459 if (srgbCapableFramebuffers)
463 if (extensionMatcher.
match(
"GL_ARB_ES3_compatibility"))
484 if (
d->m_features == -1)
486 return QOpenGLFunctions::OpenGLFeatures(
d->m_features);
503 if (
d->m_features == -1)
505 return (
d->m_features &
int(feature)) != 0;
522 if (
d->m_extensions == -1)
524 return QOpenGLExtensions::OpenGLExtensions(
d->m_extensions);
541 if (
d->m_extensions == -1)
543 return (
d->m_extensions &
int(
extension)) != 0;
2072 static const struct {
2085 size_t size = strlen(funcName);
2087 memcpy(fn, funcName,
size);
2090 for (
const auto &
e : extensions) {
2091 memcpy(
ext,
e.name,
e.len);
2101template <
typename Func>
2109#define RESOLVE(name) \
2110 resolve(context, "gl"#name, name)
2112#if !QT_CONFIG(opengles2)
2157#if !QT_CONFIG(opengles2)
2160 if (!
f.ClearDepthf || !es)
2162 if (!
f.DepthRangef || !es)
2164 if (!
f.GetShaderPrecisionFormat)
2170 if (!
f.ReleaseShaderCompiler)
5047 flushVendorChecked(
false)
5051 MapBuffer =
RESOLVE(MapBuffer);
5052 GetBufferSubData =
RESOLVE(GetBufferSubData);
5053 DiscardFramebuffer =
RESOLVE(DiscardFramebuffer);
5067 const char *vendor = (
const char *)
glGetString(GL_VENDOR);
5069 static const char *
const flushEnough[] = {
"Apple",
"ATI",
"Intel",
"NVIDIA" };
5070 for (
size_t i = 0;
i <
sizeof(flushEnough) /
sizeof(
const char *); ++
i) {
5071 if (strstr(vendor, flushEnough[
i])) {
static QPlatformNativeInterface * platformNativeInterface()
static QOpenGLContextGroup * currentContextGroup()
Returns the QOpenGLContextGroup corresponding to the current context.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
bool isOpenGLES() const
Returns true if the context is an OpenGL ES context.
bool match(const QByteArray &extension) const
bool flushIsSufficientToSyncContexts
QOpenGLExtensionsPrivate * d() const
OpenGLExtensions openGLExtensions()
Returns the set of extensions that are present on this system's OpenGL implementation.
@ PVRTCTextureCompression
bool hasOpenGLExtension(QOpenGLExtensions::OpenGLExtension extension) const
Returns true if extension is present on this system's OpenGL implementation; false otherwise.
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
OpenGLFeature
This enum defines OpenGL and OpenGL ES features whose presence may depend on the implementation.
QOpenGLFunctionsPrivate * d_ptr
void glFinish()
Convenience function that calls glFinish().
const GLubyte * glGetString(GLenum name)
Convenience function that calls glGetString(name).
void glFlush()
Convenience function that calls glFlush().
QOpenGLFunctions()
Constructs a default function resolver.
void initializeOpenGLFunctions()
Initializes OpenGL function resolution for the current context.
bool hasOpenGLFeature(QOpenGLFunctions::OpenGLFeature feature) const
Returns true if feature is present on this system's OpenGL implementation; false otherwise.
QOpenGLFunctions::OpenGLFeatures openGLFeatures() const
Returns the set of features that are present on this system's OpenGL implementation.
The QOpenGLMultiGroupSharedResource keeps track of a shared resource that might be needed from multip...
The QOpenGLSharedResource class is used to keep track of resources that are shared between OpenGL con...
\macro QT_RESTRICTED_CAST_FROM_ASCII
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
static VulkanServerBufferGlFunctions * funcs
Combined button and popup list for selecting options.
std::pair< T1, T2 > QPair
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define QOPENGLF_APIENTRY
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLdouble GLdouble GLdouble GLdouble GLdouble GLdouble zFar
GLdouble GLdouble GLdouble GLdouble GLdouble zNear
GLint GLenum GLsizei GLsizei GLsizei depth
GLenum GLuint GLintptr GLsizeiptr size
[1]
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLboolean(GL_APIENTRYP PFNGLISENABLEDIOESPROC)(GLenum target
GLint GLsizei GLsizei GLenum format
const void * getProcAddress
GLenum GLint GLint * precision
#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT
static void QOPENGLF_APIENTRY qopenglfSpecialClearDepthf(GLclampf depth)
static void QOPENGLF_APIENTRY qopenglfSpecialDepthRangef(GLclampf zNear, GLclampf zFar)
static GLboolean QOPENGLF_APIENTRY qopenglfSpecialIsShader(GLuint shader)
#define QT_OPENGL_IMPLEMENT(CLASS, FUNCTIONS)
static void QOPENGLF_APIENTRY qopenglfSpecialGetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision)
static int qt_gl_resolve_extensions()
static QOpenGLFunctionsPrivateEx * qt_gl_functions(QOpenGLContext *context=nullptr)
static void QOPENGLF_APIENTRY qopenglfSpecialReleaseShaderCompiler()
static int qt_gl_resolve_features()
static GLboolean QOPENGLF_APIENTRY qopenglfSpecialIsProgram(GLuint program)
#define QT_OPENGL_FUNCTIONS(F)
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
static QT_BEGIN_NAMESPACE void init(QTextBoundaryFinder::BoundaryType type, QStringView str, QCharAttributes *attributes)
QSvgRenderer * renderer
[0]
void freeResource(QOpenGLContext *) override
QOpenGLFunctionsPrivateEx(QOpenGLContext *context)
void invalidateResource() override
QOpenGLFunctionsPrivate(QOpenGLContext *ctx)