equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtOpenGL module of the Qt Toolkit. |
7 ** This file is part of the QtOpenGL module of the Qt Toolkit. |
8 ** |
8 ** |
79 } |
79 } |
80 if (screen->classId() == QScreen::GLClass) |
80 if (screen->classId() == QScreen::GLClass) |
81 return static_cast<QGLScreen *>(screen); |
81 return static_cast<QGLScreen *>(screen); |
82 else |
82 else |
83 return 0; |
83 return 0; |
|
84 } |
|
85 |
|
86 /* |
|
87 QGLTemporaryContext implementation |
|
88 */ |
|
89 |
|
90 class QGLTemporaryContextPrivate |
|
91 { |
|
92 public: |
|
93 QGLWidget *widget; |
|
94 }; |
|
95 |
|
96 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) |
|
97 : d(new QGLTemporaryContextPrivate) |
|
98 { |
|
99 d->widget = new QGLWidget; |
|
100 d->widget->makeCurrent(); |
|
101 } |
|
102 |
|
103 QGLTemporaryContext::~QGLTemporaryContext() |
|
104 { |
|
105 delete d->widget; |
84 } |
106 } |
85 |
107 |
86 /***************************************************************************** |
108 /***************************************************************************** |
87 QOpenGL debug facilities |
109 QOpenGL debug facilities |
88 *****************************************************************************/ |
110 *****************************************************************************/ |
174 } |
196 } |
175 |
197 |
176 // Get the display and initialize it. |
198 // Get the display and initialize it. |
177 d->eglContext = new QEglContext(); |
199 d->eglContext = new QEglContext(); |
178 d->eglContext->setApi(QEgl::OpenGL); |
200 d->eglContext->setApi(QEgl::OpenGL); |
179 if (!d->eglContext->openDisplay(device())) { |
|
180 delete d->eglContext; |
|
181 d->eglContext = 0; |
|
182 return false; |
|
183 } |
|
184 |
201 |
185 // Construct the configuration we need for this surface. |
202 // Construct the configuration we need for this surface. |
186 QEglProperties configProps; |
203 QEglProperties configProps; |
187 qt_egl_add_platform_config(configProps, device()); |
204 qt_egl_add_platform_config(configProps, device()); |
188 qt_egl_set_format(configProps, devType, d->glFormat); |
205 qt_egl_set_format(configProps, devType, d->glFormat); |
309 |
326 |
310 void QGLWidget::setColormap(const QGLColormap &) |
327 void QGLWidget::setColormap(const QGLColormap &) |
311 { |
328 { |
312 } |
329 } |
313 |
330 |
314 void QGLExtensions::init() |
|
315 { |
|
316 static bool init_done = false; |
|
317 |
|
318 if (init_done) |
|
319 return; |
|
320 init_done = true; |
|
321 |
|
322 // We need a context current to initialize the extensions, |
|
323 // but getting a valid EGLNativeWindowType this early can be |
|
324 // problematic under QWS. So use a pbuffer instead. |
|
325 // |
|
326 // Unfortunately OpenGL/ES 2.0 systems don't normally |
|
327 // support pbuffers, so we have no choice but to try |
|
328 // our luck with a window on those systems. |
|
329 #if defined(QT_OPENGL_ES_2) |
|
330 QGLWidget tmpWidget; |
|
331 tmpWidget.makeCurrent(); |
|
332 |
|
333 init_extensions(); |
|
334 |
|
335 tmpWidget.doneCurrent(); |
|
336 #else |
|
337 QGLPixelBuffer pbuffer(16, 16); |
|
338 pbuffer.makeCurrent(); |
|
339 |
|
340 init_extensions(); |
|
341 |
|
342 pbuffer.doneCurrent(); |
|
343 #endif |
|
344 } |
|
345 |
|
346 QT_END_NAMESPACE |
331 QT_END_NAMESPACE |