2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2025-05-30 13:52:30 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2018-06-01 13:13:30 +00:00
|
|
|
|
2023-04-13 10:18:12 +00:00
|
|
|
#ifndef QWASMOPENGLCONTEXT_H
|
|
|
|
#define QWASMOPENGLCONTEXT_H
|
|
|
|
|
2018-06-01 13:13:30 +00:00
|
|
|
#include <qpa/qplatformopenglcontext.h>
|
|
|
|
|
|
|
|
#include <emscripten.h>
|
|
|
|
#include <emscripten/html5.h>
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
2022-11-28 15:35:24 +00:00
|
|
|
class QOpenGLContext;
|
2019-04-28 23:19:14 +00:00
|
|
|
class QPlatformScreen;
|
2018-06-01 13:13:30 +00:00
|
|
|
class QWasmOpenGLContext : public QPlatformOpenGLContext
|
|
|
|
{
|
|
|
|
public:
|
2022-11-28 15:35:24 +00:00
|
|
|
explicit QWasmOpenGLContext(QOpenGLContext *context);
|
2018-06-01 13:13:30 +00:00
|
|
|
~QWasmOpenGLContext();
|
|
|
|
|
|
|
|
QSurfaceFormat format() const override;
|
|
|
|
void swapBuffers(QPlatformSurface *surface) override;
|
|
|
|
GLuint defaultFramebufferObject(QPlatformSurface *surface) const override;
|
|
|
|
bool makeCurrent(QPlatformSurface *surface) override;
|
|
|
|
void doneCurrent() override;
|
|
|
|
bool isSharing() const override;
|
|
|
|
bool isValid() const override;
|
|
|
|
QFunctionPointer getProcAddress(const char *procName) override;
|
|
|
|
|
|
|
|
private:
|
2020-03-10 23:56:45 +00:00
|
|
|
static bool isOpenGLVersionSupported(QSurfaceFormat format);
|
2019-04-28 23:19:14 +00:00
|
|
|
bool maybeCreateEmscriptenContext(QPlatformSurface *surface);
|
2022-11-14 08:12:34 +00:00
|
|
|
static EMSCRIPTEN_WEBGL_CONTEXT_HANDLE
|
|
|
|
createEmscriptenContext(const std::string &canvasSelector, QSurfaceFormat format);
|
2018-06-01 13:13:30 +00:00
|
|
|
|
|
|
|
QSurfaceFormat m_requestedFormat;
|
2022-11-14 08:12:34 +00:00
|
|
|
QPlatformSurface *m_surface = nullptr;
|
2022-11-28 15:35:24 +00:00
|
|
|
QOpenGLContext *m_qGlContext;
|
|
|
|
EMSCRIPTEN_WEBGL_CONTEXT_HANDLE m_webGLContext = 0;
|
2018-06-01 13:13:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2023-04-13 10:18:12 +00:00
|
|
|
#endif // QWASMOPENGLCONTEXT_H
|