diff options
author | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-07 17:25:22 +0200 |
---|---|---|
committer | Samuel Rødal <samuel.rodal@nokia.com> | 2011-06-10 09:24:56 +0200 |
commit | 4a189c188ccd2fb5f8d1d5ddadf06cbd6bc0916f (patch) | |
tree | 99bff9f015e869b5521836ea5667590939b22a53 /src/plugins/platforms/cocoa/qcocoaglcontext.h | |
parent | 4d10e64f2a78e32418a98e1c80c6579ae0779dfc (diff) |
QWindowContext / QWindowFormat refactor.
To enable having a single GL context used for multiple drawables we need
to de-couple the context class a bit more from the window class in the
plugin API. Now contexts are created stand-alone based on a GL format
and a share context, and when calling makeCurrent() a desired surface
is specified. This maps well to GLX, EGL, Cocoa, AGL, and WGL, which all
support this use case.
QWindowContext is renamed to QGuiGLContext, and QWindowFormat is renamed
to QGuiGLFormat. We have the ability to introduce a pbuffer or similar
other offscreen GL drawable abstraction in the future.
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoaglcontext.h')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.h | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 4d330a4294..01d931b662 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -1,26 +1,52 @@ #ifndef QCOCOAGLCONTEXT_H #define QCOCOAGLCONTEXT_H +#include <QtCore/QWeakPointer> #include <QtGui/QPlatformGLContext> -#include <QtGui/QWindowFormat> +#include <QtGui/QGuiGLContext> +#include <QtGui/QWindow> #include <Cocoa/Cocoa.h> QT_BEGIN_NAMESPACE +class QCocoaGLSurface : public QPlatformGLSurface +{ +public: + QCocoaGLSurface(const QGuiGLFormat &format, QWindow *window) + : QPlatformGLSurface(format) + , window(window) + { + } + + QWindow *window; +}; + class QCocoaGLContext : public QPlatformGLContext { public: - QCocoaGLContext(NSOpenGLView *glView); - void makeCurrent(); + QCocoaGLContext(const QGuiGLFormat &format, QPlatformGLContext *share); + + QGuiGLFormat format() const; + + void swapBuffers(const QPlatformGLSurface &surface); + + bool makeCurrent(const QPlatformGLSurface &surface); void doneCurrent(); - void swapBuffers(); - void* getProcAddress(const QString& procName); - QWindowFormat windowFormat() const; + + void (*getProcAddress(const QByteArray &procName)) (); + + void update(); + static NSOpenGLPixelFormat *createNSOpenGLPixelFormat(); NSOpenGLContext *nsOpenGLContext() const; + private: - NSOpenGLView *m_glView; + void setActiveWindow(QWindow *window); + + NSOpenGLContext *m_context; + QGuiGLFormat m_format; + QWeakPointer<QWindow> m_currentWindow; }; QT_END_NAMESPACE |