48 #include "../eglconvenience/qeglconvenience.h" 50 #include <QtGui/QWidget> 59 mPlatformWindow(platformWindow),
60 mEglSurface(EGL_NO_SURFACE)
62 #if defined(QBBGLCONTEXT_DEBUG) 69 qFatal(
"QBB: window API is not OpenGL");
73 EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
74 if (eglResult != EGL_TRUE) {
75 qFatal(
"QBB: failed to set EGL API, err=%d", eglGetError());
85 if (alphaSize == -1 && redSize == -1 && greenSize == -1 && blueSize == -1) {
106 if (alphaSize <= 0 && redSize <= 5 && greenSize <= 6 && blueSize <= 5) {
130 qFatal(
"QBB: failed to find EGL config");
135 qFatal(
"QBB: failed to create EGL context, err=%d", eglGetError());
144 #if defined(QBBGLCONTEXT_DEBUG) 162 qFatal(
"QBB: failed to obtain EGL display");
165 EGLBoolean eglResult = eglInitialize(
sEglDisplay, NULL, NULL);
166 if (eglResult != EGL_TRUE) {
167 qFatal(
"QBB: failed to initialize EGL display, err=%d", eglGetError());
171 #if defined(QT_OPENGL_ES_2) 172 EGLint renderableType = EGL_OPENGL_ES2_BIT;
174 EGLint renderableType = EGL_OPENGL_ES_BIT;
186 #if defined(QBBGLCONTEXT_DEBUG) 202 EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
203 if (eglResult != EGL_TRUE) {
204 qFatal(
"QBB: failed to set EGL API, err=%d", eglGetError());
209 if (eglResult != EGL_TRUE) {
210 qFatal(
"QBB: failed to set current EGL context, err=%d", eglGetError());
216 #if defined(QBBGLCONTEXT_DEBUG) 224 EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
225 if (eglResult != EGL_TRUE) {
226 qFatal(
"QBB: failed to set EGL API, err=%d", eglGetError());
230 eglResult = eglMakeCurrent(
sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
231 if (eglResult != EGL_TRUE) {
232 qFatal(
"QBB: failed to clear current EGL context, err=%d", eglGetError());
238 #if defined(QBBGLCONTEXT_DEBUG) 243 EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
244 if (eglResult != EGL_TRUE) {
245 qFatal(
"QBB: failed to set EGL API, err=%d", eglGetError());
250 if (eglResult != EGL_TRUE) {
251 qFatal(
"QBB: failed to swap EGL buffers, err=%d", eglGetError());
263 #if defined(QBBGLCONTEXT_DEBUG) 268 EGLBoolean eglResult = eglBindAPI(EGL_OPENGL_ES_API);
269 if (eglResult != EGL_TRUE) {
270 qFatal(
"QBB: failed to set EGL API, err=%d", eglGetError());
280 bool restoreCurrent =
false;
283 restoreCurrent =
true;
297 if (restoreCurrent) {
306 #if defined(QT_OPENGL_ES_2) 307 static EGLint attrs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
321 #if defined(QBBGLCONTEXT_DEBUG) 328 qFatal(
"QBB: failed to create EGL surface, err=%d", eglGetError());
334 #if defined(QBBGLCONTEXT_DEBUG) 341 if (eglResult != EGL_TRUE) {
342 qFatal(
"QBB: failed to destroy EGL surface, err=%d", eglGetError());
virtual void swapBuffers()
Reimplement in subclass to native swap buffers calls.
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
#define QT_END_NAMESPACE
This macro expands to.
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
virtual void doneCurrent()
Reimplement in subclass to release current context.
void setBufferSize(const QSize &size)
virtual void * getProcAddress(const QString &procName)
Reimplement in subclass to native getProcAddr calls.
The QString class provides a Unicode character string.
NativeWindowType EGLNativeWindowType
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
QBBScreen * screen() const
void resizeSurface(const QSize &size)
QSize size() const
Returns the size of the rectangle.
QBBWindow * mPlatformWindow
virtual int depth() const
Reimplement in subclass to return current depth of the screen.
QBBGLContext(QBBWindow *platformWindow)
virtual void makeCurrent()
Reimplement in subclass to do makeCurrent on native GL context.
static EGLint * contextAttrs()
const char * constData() const
Returns a pointer to the data stored in the byte array.
Q_CORE_EXPORT void qFatal(const char *,...)
The QPlatformGLContext class provides an abstraction for native GL contexts.
virtual WId winId() const
Reimplement in subclasses to return a handle to the native window.
QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
QByteArray toAscii() const Q_REQUIRED_RESULT
Returns an 8-bit representation of the string as a QByteArray.
QPlatformWindowFormat mWindowFormat
The QSize class defines the size of a two-dimensional object using integer point precision.
virtual void doneCurrent()
Reimplement in subclass to release current context.
static EGLDisplay sEglDisplay