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

#include <qeglplatformcontext.h>

Inheritance diagram for QEGLPlatformContext:
QPlatformGLContext

Public Functions

void doneCurrent ()
 Reimplement in subclass to release current context. More...
 
EGLContext eglContext () const
 
void * getProcAddress (const QString &procName)
 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...
 
 QEGLPlatformContext (EGLDisplay display, EGLConfig config, EGLint contextAttrs[], EGLSurface surface, EGLenum eglApi, QEGLPlatformContext *shareContext=0)
 
void swapBuffers ()
 Reimplement in subclass to native swap buffers calls. More...
 
 ~QEGLPlatformContext ()
 
- 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...
 

Properties

EGLenum m_eglApi
 
EGLContext m_eglContext
 
EGLDisplay m_eglDisplay
 
EGLSurface m_eglSurface
 
QPlatformWindowFormat m_windowFormat
 

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 48 of file qeglplatformcontext.h.

Constructors and Destructors

◆ QEGLPlatformContext()

QEGLPlatformContext::QEGLPlatformContext ( EGLDisplay  display,
EGLConfig  config,
EGLint  contextAttrs[],
EGLSurface  surface,
EGLenum  eglApi,
QEGLPlatformContext shareContext = 0 
)

Definition at line 51 of file qeglplatformcontext.cpp.

54  , m_eglSurface(surface)
55  , m_eglApi(eglApi)
56 {
57  if (m_eglSurface == EGL_NO_SURFACE) {
58  qWarning("Createing QEGLPlatformContext with no surface");
59  }
60 
61  eglBindAPI(m_eglApi);
62  EGLContext shareEglContext = shareContext ? shareContext->eglContext() : 0;
63  m_eglContext = eglCreateContext(m_eglDisplay,config, shareEglContext, contextAttrs);
64  if (m_eglContext == EGL_NO_CONTEXT) {
65  qWarning("Could not create the egl context\n");
66  eglTerminate(m_eglDisplay);
67  qFatal("EGL error");
68  }
69 
71 }
QPlatformWindowFormat m_windowFormat
EGLContext eglContext() const
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
Q_CORE_EXPORT void qWarning(const char *,...)
Q_CORE_EXPORT void qFatal(const char *,...)
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
QPlatformGLContext()
All subclasses needs to specify the platformWindow.

◆ ~QEGLPlatformContext()

QEGLPlatformContext::~QEGLPlatformContext ( )

Definition at line 73 of file qeglplatformcontext.cpp.

74 {
75 #ifdef QEGL_EXTRA_DEBUG
76  qWarning("QEglContext::~QEglContext(): %p\n",this);
77 #endif
78  if (m_eglSurface != EGL_NO_SURFACE) {
79  doneCurrent();
80  eglDestroySurface(m_eglDisplay, m_eglSurface);
81  m_eglSurface = EGL_NO_SURFACE;
82  }
83 
84  if (m_eglContext != EGL_NO_CONTEXT) {
85  eglDestroyContext(m_eglDisplay, m_eglContext);
86  m_eglContext = EGL_NO_CONTEXT;
87  }
88 }
Q_CORE_EXPORT void qWarning(const char *,...)
void doneCurrent()
Reimplement in subclass to release current context.

Functions

◆ doneCurrent()

void QEGLPlatformContext::doneCurrent ( )
virtual

Reimplement in subclass to release current context.

Typically this is calling makeCurrent with 0 "surface"

Reimplemented from QPlatformGLContext.

Definition at line 120 of file qeglplatformcontext.cpp.

Referenced by ~QEGLPlatformContext().

121 {
123 #ifdef QEGL_EXTRA_DEBUG
124  qWarning("QEglContext::doneCurrent:%p\n",this);
125 #endif
126  eglBindAPI(m_eglApi);
127  bool ok = eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
128  if (!ok)
129  qWarning("QEGLPlatformContext::doneCurrent(): eglError: %d, this: %p \n", eglGetError(), this);
130 }
virtual void doneCurrent()
Reimplement in subclass to release current context.
Q_CORE_EXPORT void qWarning(const char *,...)

◆ eglContext()

EGLContext QEGLPlatformContext::eglContext ( ) const

Definition at line 155 of file qeglplatformcontext.cpp.

Referenced by QXcbNativeInterface::eglContextForWidget(), and QEGLPlatformContext().

156 {
157  return m_eglContext;
158 }

◆ getProcAddress()

void * QEGLPlatformContext::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 141 of file qeglplatformcontext.cpp.

142 {
143 #ifdef QEGL_EXTRA_DEBUG
144  qWarning("QEglContext::getProcAddress%p\n",this);
145 #endif
146  eglBindAPI(m_eglApi);
147  return (void *)eglGetProcAddress(qPrintable(procName));
148 }
Q_CORE_EXPORT void qWarning(const char *,...)
#define qPrintable(string)
Definition: qglobal.h:1750

◆ makeCurrent()

void QEGLPlatformContext::makeCurrent ( )
virtual

Reimplement in subclass to do makeCurrent on native GL context.

Reimplemented from QPlatformGLContext.

Definition at line 90 of file qeglplatformcontext.cpp.

91 {
93 #ifdef QEGL_EXTRA_DEBUG
94  qWarning("QEglContext::makeCurrent: %p\n",this);
95 #endif
96  eglBindAPI(m_eglApi);
97  bool ok = eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
98  if (!ok)
99  qWarning("QEGLPlatformContext::makeCurrent: eglError: %d, this: %p \n", eglGetError(), this);
100 #ifdef QEGL_EXTRA_DEBUG
101  static bool showDebug = true;
102  if (showDebug) {
103  showDebug = false;
104  const char *str = (const char*)glGetString(GL_VENDOR);
105  qWarning("Vendor %s\n", str);
106  str = (const char*)glGetString(GL_RENDERER);
107  qWarning("Renderer %s\n", str);
108  str = (const char*)glGetString(GL_VERSION);
109  qWarning("Version %s\n", str);
110 
111  str = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
112  qWarning("Extensions %s\n",str);
113 
114  str = (const char*)glGetString(GL_EXTENSIONS);
115  qWarning("Extensions %s\n", str);
116 
117  }
118 #endif
119 }
#define GL_VERSION
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
#define GL_EXTENSIONS
#define GL_VENDOR
#define GL_RENDERER
#define showDebug(f, iface)
#define GL_SHADING_LANGUAGE_VERSION

◆ platformWindowFormat()

QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat ( ) const
virtual

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 150 of file qeglplatformcontext.cpp.

151 {
152  return m_windowFormat;
153 }
QPlatformWindowFormat m_windowFormat

◆ swapBuffers()

void QEGLPlatformContext::swapBuffers ( )
virtual

Reimplement in subclass to native swap buffers calls.

Implements QPlatformGLContext.

Definition at line 131 of file qeglplatformcontext.cpp.

132 {
133 #ifdef QEGL_EXTRA_DEBUG
134  qWarning("QEglContext::swapBuffers:%p\n",this);
135 #endif
136  eglBindAPI(m_eglApi);
137  bool ok = eglSwapBuffers(m_eglDisplay, m_eglSurface);
138  if (!ok)
139  qWarning("QEGLPlatformContext::swapBuffers(): eglError: %d, this: %p \n", eglGetError(), this);
140 }
Q_CORE_EXPORT void qWarning(const char *,...)

Properties

◆ m_eglApi

EGLenum QEGLPlatformContext::m_eglApi
private

◆ m_eglContext

EGLContext QEGLPlatformContext::m_eglContext
private

◆ m_eglDisplay

EGLDisplay QEGLPlatformContext::m_eglDisplay
private

◆ m_eglSurface

EGLSurface QEGLPlatformContext::m_eglSurface
private

◆ m_windowFormat

QPlatformWindowFormat QEGLPlatformContext::m_windowFormat
private

Definition at line 68 of file qeglplatformcontext.h.

Referenced by platformWindowFormat(), and QEGLPlatformContext().


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