Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qwaylandbrcmglcontext.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <QtWaylandClient/private/qwaylanddisplay_p.h>
7#include <QtWaylandClient/private/qwaylandwindow_p.h>
9
10#include <QtGui/private/qeglconvenience_p.h>
11
12#include <qpa/qplatformopenglcontext.h>
13#include <QtGui/QSurfaceFormat>
14
15#include <dlfcn.h>
16
17QT_BEGIN_NAMESPACE
18
19namespace QtWaylandClient {
20
21extern QSurfaceFormat brcmFixFormat(const QSurfaceFormat &format);
22
24
25QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
27 , m_eglDisplay(eglDisplay)
30{
31 EGLContext shareEGLContext = share ? static_cast<QWaylandBrcmGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
32
33 eglBindAPI(EGL_OPENGL_ES_API);
34
35 QList<EGLint> eglContextAttrs;
36 eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
37 eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2);
38 eglContextAttrs.append(EGL_NONE);
39
40 m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData());
41}
42
44{
45 eglDestroyContext(m_eglDisplay, m_context);
46}
47
48bool QWaylandBrcmGLContext::makeCurrent(QPlatformSurface *surface)
49{
50 return static_cast<QWaylandBrcmEglWindow *>(surface)->makeCurrent(m_context);
51}
52
54{
55 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
56}
57
58void QWaylandBrcmGLContext::swapBuffers(QPlatformSurface *surface)
59{
60 static_cast<QWaylandBrcmEglWindow *>(surface)->swapBuffers();
61}
62
64{
65 QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName);
66 if (!proc)
67 proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName);
68 return proc;
69}
70
72{
73 return m_config;
74}
75
76}
77
78QT_END_NAMESPACE
void swapBuffers(QPlatformSurface *surface) override
Reimplement in subclass to native swap buffers calls.
bool makeCurrent(QPlatformSurface *surface) override
QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
QFunctionPointer getProcAddress(const char *procName) override
Reimplement in subclass to allow dynamic querying of OpenGL symbols.
QSurfaceFormat brcmFixFormat(const QSurfaceFormat &f)