1// Copyright (C) 2020 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
4#ifndef QOPENGLCONTEXT_PLATFORM_H
5#define QOPENGLCONTEXT_PLATFORM_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is part of the native interface APIs. Usage of
12// this API may make your code source and binary incompatible
13// with future versions of Qt.
14//
15
16#ifndef QT_NO_OPENGL
17
18#include <QtGui/qtguiglobal.h>
19#include <QtGui/qopenglcontext.h>
20#include <QtGui/qwindowdefs.h>
21
22#include <QtCore/qnativeinterface.h>
23
24#if defined(Q_OS_MACOS)
25Q_FORWARD_DECLARE_OBJC_CLASS(NSOpenGLContext);
26#endif
27
28#if QT_CONFIG(xcb_glx_plugin)
29struct __GLXcontextRec; typedef struct __GLXcontextRec *GLXContext;
30#endif
31#if QT_CONFIG(egl)
32typedef void *EGLContext;
33typedef void *EGLDisplay;
34typedef void *EGLConfig;
35#endif
36
37#if !defined(Q_OS_MACOS) && defined(Q_QDOC)
38typedef void *NSOpenGLContext;
39#endif
40
41QT_BEGIN_NAMESPACE
42
43namespace QNativeInterface {
44
45#if defined(Q_OS_MACOS) || defined(Q_QDOC)
46struct Q_GUI_EXPORT QCocoaGLContext
47{
48 QT_DECLARE_NATIVE_INTERFACE(QCocoaGLContext, 1, QOpenGLContext)
49 static QOpenGLContext *fromNative(QT_IGNORE_DEPRECATIONS(NSOpenGLContext) *context, QOpenGLContext *shareContext = nullptr);
50 virtual QT_IGNORE_DEPRECATIONS(NSOpenGLContext) *nativeContext() const = 0;
51};
52#endif
53
54#if defined(Q_OS_WIN) || defined(Q_QDOC)
55struct Q_GUI_EXPORT QWGLContext
56{
57 QT_DECLARE_NATIVE_INTERFACE(QWGLContext, 1, QOpenGLContext)
58 static HMODULE openGLModuleHandle();
59 static QOpenGLContext *fromNative(HGLRC context, HWND window, QOpenGLContext *shareContext = nullptr);
60 virtual HGLRC nativeContext() const = 0;
61};
62#endif
63
64#if QT_CONFIG(xcb_glx_plugin) || defined(Q_QDOC)
65struct Q_GUI_EXPORT QGLXContext
66{
67 QT_DECLARE_NATIVE_INTERFACE(QGLXContext, 1, QOpenGLContext)
68 static QOpenGLContext *fromNative(GLXContext configBasedContext, QOpenGLContext *shareContext = nullptr);
69 static QOpenGLContext *fromNative(GLXContext visualBasedContext, void *visualInfo, QOpenGLContext *shareContext = nullptr);
70 virtual GLXContext nativeContext() const = 0;
71};
72#endif
73
74#if QT_CONFIG(egl) || defined(Q_QDOC)
75struct Q_GUI_EXPORT QEGLContext
76{
77 QT_DECLARE_NATIVE_INTERFACE(QEGLContext, 1, QOpenGLContext)
78 static QOpenGLContext *fromNative(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext = nullptr);
79 virtual EGLContext nativeContext() const = 0;
80 virtual EGLConfig config() const = 0;
81 virtual EGLDisplay display() const = 0;
82
83 virtual void invalidateContext() = 0;
84};
85#endif
86
87} // QNativeInterface
88
89QT_END_NAMESPACE
90
91#endif // QT_NO_OPENGL
92
93#endif // QOPENGLCONTEXT_PLATFORM_H
94

source code of qtbase/src/gui/kernel/qopenglcontext_platform.h