Qt 4.8
Public Functions | Private Functions | Properties | List of all members
QWaylandGLContext Class Reference

#include <qwaylandglcontext.h>

Inheritance diagram for QWaylandGLContext:
QPlatformGLContext

Public Functions

void doneCurrent ()
 Reimplement in subclass to release current context. More...
 
EGLConfig eglConfig () const
 
void * getProcAddress (const QString &)
 Reimplement in subclass to native getProcAddr calls. More...
 
void makeCurrent ()
 Reimplement in subclass to do makeCurrent on native GL context. More...
 
QPlatformWindowFormat platformWindowFormat () const
 QWidget has the function qplatformWindowFormat(). More...
 
 QWaylandGLContext (EGLDisplay eglDisplay, const QPlatformWindowFormat &format)
 
void setEglSurface (EGLSurface surface)
 
void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
 ~QWaylandGLContext ()
 
- Public Functions inherited from QPlatformGLContext
 QPlatformGLContext ()
 All subclasses needs to specify the platformWindow. More...
 
virtual ~QPlatformGLContext ()
 If this is the current context for the thread, doneCurrent is called. More...
 

Private Functions

 QWaylandGLContext ()
 

Properties

EGLConfig mConfig
 
EGLContext mContext
 
EGLDisplay mEglDisplay
 
QPlatformWindowFormat mFormat
 
EGLSurface mSurface
 

Additional Inherited Members

- Static Public Functions inherited from QPlatformGLContext
static const QPlatformGLContextcurrentContext ()
 Returns the last context which called makeCurrent. More...
 
- Protected Variables inherited from QPlatformGLContext
QScopedPointer< QPlatformGLContextPrivated_ptr
 

Detailed Description

Definition at line 54 of file qwaylandglcontext.h.

Constructors and Destructors

◆ QWaylandGLContext() [1/2]

QWaylandGLContext::QWaylandGLContext ( EGLDisplay  eglDisplay,
const QPlatformWindowFormat format 
)

Definition at line 53 of file qwaylandglcontext.cpp.

55  , mEglDisplay(eglDisplay)
56  , mSurface(EGL_NO_SURFACE)
59 {
60  QPlatformGLContext *sharePlatformContext = 0;
61  sharePlatformContext = format.sharedGLContext();
62  mFormat.setSharedContext(sharePlatformContext);
63  EGLContext shareEGLContext = EGL_NO_CONTEXT;
64  if (sharePlatformContext)
65  shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;
66 
67  eglBindAPI(EGL_OPENGL_ES_API);
68 
69  QVector<EGLint> eglContextAttrs;
70  eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
71  eglContextAttrs.append(2);
72  eglContextAttrs.append(EGL_NONE);
73 
74  mContext = eglCreateContext(mEglDisplay, mConfig,
75  shareEGLContext, eglContextAttrs.constData());
76 }
void setSharedContext(QPlatformGLContext *context)
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
QPlatformGLContext * sharedGLContext() const
QPlatformWindowFormat mFormat
void append(const T &t)
Inserts value at the end of the vector.
Definition: qvector.h:573
The QPlatformGLContext class provides an abstraction for native GL contexts.
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
QPlatformGLContext()
All subclasses needs to specify the platformWindow.
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

◆ ~QWaylandGLContext()

QWaylandGLContext::~QWaylandGLContext ( )

Definition at line 86 of file qwaylandglcontext.cpp.

87 {
88  eglDestroyContext(mEglDisplay,mContext);
89 }

◆ QWaylandGLContext() [2/2]

QWaylandGLContext::QWaylandGLContext ( )
private

Definition at line 78 of file qwaylandglcontext.cpp.

80  , mEglDisplay(0)
81  , mContext(EGL_NO_CONTEXT)
82  , mSurface(EGL_NO_SURFACE)
83  , mConfig(0)
84 { }
QPlatformGLContext()
All subclasses needs to specify the platformWindow.

Functions

◆ doneCurrent()

void QWaylandGLContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 100 of file qwaylandglcontext.cpp.

Referenced by setEglSurface().

101 {
103  eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
104 }
virtual void doneCurrent()
Reimplement in subclass to release current context.

◆ eglConfig()

EGLConfig QWaylandGLContext::eglConfig ( ) const

Definition at line 129 of file qwaylandglcontext.cpp.

Referenced by QWaylandEglWindow::glContext(), QWaylandEglWindow::newSurfaceCreated(), and platformWindowFormat().

130 {
131  return mConfig;
132 }

◆ getProcAddress()

void * QWaylandGLContext::getProcAddress ( const QString procName)
virtual

Reimplement in subclass to native getProcAddr calls.

Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer

Implements QPlatformGLContext.

Definition at line 111 of file qwaylandglcontext.cpp.

112 {
113  return (void *) eglGetProcAddress(string.toLatin1().data());
114 }
static const char * data(const QByteArray &arr)

◆ makeCurrent()

void QWaylandGLContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 91 of file qwaylandglcontext.cpp.

Referenced by setEglSurface().

92 {
94  if (mSurface == EGL_NO_SURFACE) {
95  qWarning("makeCurrent with EGL_NO_SURFACE");
96  }
97  eglMakeCurrent(mEglDisplay, mSurface, mSurface, mContext);
98 }
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.

◆ platformWindowFormat()

QPlatformWindowFormat QWaylandGLContext::platformWindowFormat ( ) const
inlinevirtual

QWidget has the function qplatformWindowFormat().

That function is for the application programmer to request the format of the window and the context that he wants.

Reimplement this function in a subclass to indicate what format the glContext actually has.

Implements QPlatformGLContext.

Definition at line 63 of file qwaylandglcontext.h.

63 { return mFormat; }
QPlatformWindowFormat mFormat

◆ setEglSurface()

void QWaylandGLContext::setEglSurface ( EGLSurface  surface)

Definition at line 116 of file qwaylandglcontext.cpp.

Referenced by QWaylandEglWindow::glContext(), QWaylandEglWindow::newSurfaceCreated(), and platformWindowFormat().

117 {
118  bool wasCurrent = false;
119  if (QPlatformGLContext::currentContext() == this) {
120  wasCurrent = true;
121  doneCurrent();
122  }
123  mSurface = surface;
124  if (wasCurrent) {
125  makeCurrent();
126  }
127 }
static const QPlatformGLContext * currentContext()
Returns the last context which called makeCurrent.
void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
void doneCurrent()
Reimplement in subclass to release current context.

◆ swapBuffers()

void QWaylandGLContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 106 of file qwaylandglcontext.cpp.

107 {
108  eglSwapBuffers(mEglDisplay,mSurface);
109 }

Properties

◆ mConfig

EGLConfig QWaylandGLContext::mConfig
private

Definition at line 72 of file qwaylandglcontext.h.

Referenced by eglConfig(), and QWaylandGLContext().

◆ mContext

EGLContext QWaylandGLContext::mContext
private

Definition at line 70 of file qwaylandglcontext.h.

Referenced by makeCurrent(), QWaylandGLContext(), and ~QWaylandGLContext().

◆ mEglDisplay

EGLDisplay QWaylandGLContext::mEglDisplay
private

◆ mFormat

QPlatformWindowFormat QWaylandGLContext::mFormat
private

Definition at line 73 of file qwaylandglcontext.h.

Referenced by platformWindowFormat(), and QWaylandGLContext().

◆ mSurface

EGLSurface QWaylandGLContext::mSurface
private

Definition at line 71 of file qwaylandglcontext.h.

Referenced by makeCurrent(), setEglSurface(), and swapBuffers().


The documentation for this class was generated from the following files: