1 /****************************************************************************
2 **
3 ** Copyright (C) 2008-2012 NVIDIA Corporation.
4 ** Copyright (C) 2019 The Qt Company Ltd.
5 ** Contact: https://www.qt.io/licensing/
6 **
7 ** This file is part of Qt Quick 3D.
8 **
9 ** $QT_BEGIN_LICENSE:GPL$
10 ** Commercial License Usage
11 ** Licensees holding valid commercial Qt licenses may use this file in
12 ** accordance with the commercial license agreement provided with the
13 ** Software or, alternatively, in accordance with the terms contained in
14 ** a written agreement between you and The Qt Company. For licensing terms
15 ** and conditions see https://www.qt.io/terms-conditions. For further
16 ** information use the contact form at https://www.qt.io/contact-us.
17 **
18 ** GNU General Public License Usage
19 ** Alternatively, this file may be used under the terms of the GNU
20 ** General Public License version 3 or (at your option) any later version
21 ** approved by the KDE Free Qt Foundation. The licenses are as published by
22 ** the Free Software Foundation and appearing in the file LICENSE.GPL3
23 ** included in the packaging of this file. Please review the following
24 ** information to ensure the GNU General Public License requirements will
25 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
26 **
27 ** $QT_END_LICENSE$
28 **
29 ****************************************************************************/
30 
31 
32 #include "qssgopenglextensions_p.h"
33 
34 QT_BEGIN_NAMESPACE
35 
QSSGOpenGLExtensions()36 QSSGOpenGLExtensions::QSSGOpenGLExtensions() : QAbstractOpenGLExtension(*(new QSSGOpenGLExtensionsPrivate)) {}
37 
initializeOpenGLFunctions()38 bool QSSGOpenGLExtensions::initializeOpenGLFunctions()
39 {
40     if (isInitialized())
41         return true;
42 
43     QT_PREPEND_NAMESPACE(QOpenGLContext) *context = QT_PREPEND_NAMESPACE(QOpenGLContext)::currentContext();
44     if (!context) {
45         qWarning("A current OpenGL context is required to resolve functions");
46         return false;
47     }
48 
49     Q_D(QSSGOpenGLExtensions);
50 
51     d->BlendBarrierNV = reinterpret_cast<void(QOPENGLF_APIENTRYP)()>(context->getProcAddress("glBlendBarrierNV"));
52     QAbstractOpenGLExtension::initializeOpenGLFunctions();
53     return true;
54 }
55 
56 #if defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2_ANGLE)
QSSGOpenGLES2Extensions()57 QSSGOpenGLES2Extensions::QSSGOpenGLES2Extensions() {}
58 
initializeOpenGLFunctions()59 bool QSSGOpenGLES2Extensions::initializeOpenGLFunctions()
60 {
61     if (isInitialized())
62         return true;
63 
64     QT_PREPEND_NAMESPACE(QOpenGLContext) *context = QT_PREPEND_NAMESPACE(QOpenGLContext)::currentContext();
65     if (!context) {
66         qWarning("A current OpenGL context is required to resolve functions");
67         return false;
68     }
69 
70     Q_D(QSSGOpenGLExtensions);
71 
72 #if defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2_ANGLE)
73     d->PatchParameteriEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLenum, GLint)>(
74             context->getProcAddress("glPatchParameteriEXT"));
75     d->QueryCounterEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLuint, GLenum)>(
76             context->getProcAddress("glQueryCounterEXT"));
77     d->GetQueryObjectui64vEXT = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLuint, GLenum, GLuint64 *)>(
78             context->getProcAddress("glGetQueryObjectui64vEXT"));
79     d->BindVertexArrayOES = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLuint)>(
80             context->getProcAddress("glBindVertexArrayOES"));
81     d->DeleteVertexArraysOES = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLsizei, const GLuint *)>(
82             context->getProcAddress("glDeleteVertexArraysOES"));
83     d->GenVertexArraysOES = reinterpret_cast<void(QOPENGLF_APIENTRYP)(GLsizei, GLuint *)>(
84             context->getProcAddress("glGenVertexArraysOES"));
85     d->IsVertexArrayOES = reinterpret_cast<GLboolean(QOPENGLF_APIENTRYP)(GLuint)>(
86             context->getProcAddress("glIsVertexArrayOES"));
87 #endif
88     QSSGOpenGLExtensions::initializeOpenGLFunctions();
89     return true;
90 }
91 #endif // QT_OPENGL_ES
92 
93 QT_END_NAMESPACE
94