6b2e6cfd53
One of the annoying things about EGL headers is that they include platform headers by default, e.g. on X11, it's Xlib.h, etc. The problem with Xlib.h is that it uses the define compiler directive to declare constants and those constants have very generic names, e.g. 'None', which typically conflict with enums, etc. In order to work around bad things coming from Xlib.h, we include fixx11.h file that contains some workarounds to redefine some Xlib's types. There's a flag or rather two flags (EGL_NO_PLATFORM_SPECIFIC_TYPES and EGL_NO_X11) that are cross-vendor and they can be used to prevent EGL headers from including platform specific headers, such as Xlib.h [1] The benefit of setting those two flags is that you can simply include EGL/egl.h or epoxy/egl.h and the world won't explode due to Xlib.h MESA_EGL_NO_X11_HEADERS is set to support older versions of Mesa. [1] https://github.com/KhronosGroup/EGL-Registry/pull/111
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
/*
|
|
KWin - the KDE window manager
|
|
This file is part of the KDE project.
|
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <epoxy/egl.h>
|
|
#include "fixqopengl.h"
|
|
|
|
#include <qpa/qplatformopenglcontext.h>
|
|
|
|
namespace KWin
|
|
{
|
|
namespace QPA
|
|
{
|
|
|
|
class EGLPlatformContext : public QPlatformOpenGLContext
|
|
{
|
|
public:
|
|
EGLPlatformContext(QOpenGLContext *context, EGLDisplay display);
|
|
~EGLPlatformContext() override;
|
|
|
|
bool makeCurrent(QPlatformSurface *surface) override;
|
|
void doneCurrent() override;
|
|
QSurfaceFormat format() const override;
|
|
bool isValid() const override;
|
|
bool isSharing() const override;
|
|
GLuint defaultFramebufferObject(QPlatformSurface *surface) const override;
|
|
QFunctionPointer getProcAddress(const char *procName) override;
|
|
void swapBuffers(QPlatformSurface *surface) override;
|
|
|
|
EGLDisplay eglDisplay() const;
|
|
EGLContext eglContext() const;
|
|
|
|
private:
|
|
void create(const QSurfaceFormat &format, EGLContext shareContext);
|
|
void updateFormatFromContext();
|
|
|
|
EGLDisplay m_eglDisplay;
|
|
EGLConfig m_config = EGL_NO_CONFIG_KHR;
|
|
EGLContext m_context = EGL_NO_CONTEXT;
|
|
QSurfaceFormat m_format;
|
|
};
|
|
|
|
} // namespace QPA
|
|
} // namespace KWin
|