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
23QWaylandBrcmGLContext::QWaylandBrcmGLContext(EGLDisplay eglDisplay, const QSurfaceFormat &format, QPlatformOpenGLContext *share)
25 , m_eglDisplay(eglDisplay)
28{
29 EGLContext shareEGLContext = share ? static_cast<QWaylandBrcmGLContext *>(share)->eglContext() : EGL_NO_CONTEXT;
30
31 eglBindAPI(EGL_OPENGL_ES_API);
32
33 QList<EGLint> eglContextAttrs;
34 eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
35 eglContextAttrs.append(format.majorVersion() == 1 ? 1 : 2);
36 eglContextAttrs.append(EGL_NONE);
37
38 m_context = eglCreateContext(m_eglDisplay, m_config, shareEGLContext, eglContextAttrs.constData());
39}
40
42{
43 eglDestroyContext(m_eglDisplay, m_context);
44}
45
46bool QWaylandBrcmGLContext::makeCurrent(QPlatformSurface *surface)
47{
48 return static_cast<QWaylandBrcmEglWindow *>(surface)->makeCurrent(m_context);
49}
50
52{
53 eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
54}
55
56void QWaylandBrcmGLContext::swapBuffers(QPlatformSurface *surface)
57{
58 static_cast<QWaylandBrcmEglWindow *>(surface)->swapBuffers();
59}
60
62{
63 QFunctionPointer proc = (QFunctionPointer) eglGetProcAddress(procName);
64 if (!proc)
65 proc = (QFunctionPointer) dlsym(RTLD_DEFAULT, procName);
66 return proc;
67}
68
69EGLConfig QWaylandBrcmGLContext::eglConfig() const
70{
71 return m_config;
72}
73
74}
75
76QT_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)