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 ** |
93 #ifndef QGLCMAP_H |
93 #ifndef QGLCMAP_H |
94 #define QGLCMAP_H |
94 #define QGLCMAP_H |
95 |
95 |
96 #include <qcolor.h> |
96 #include <qcolor.h> |
97 |
97 |
98 |
98 /* |
99 |
99 QGLTemporaryContext implementation |
|
100 */ |
|
101 |
|
102 class QGLTemporaryContextPrivate |
|
103 { |
|
104 public: |
|
105 QGLWidget *widget; |
|
106 }; |
|
107 |
|
108 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) |
|
109 : d(new QGLTemporaryContextPrivate) |
|
110 { |
|
111 d->widget = new QGLWidget; |
|
112 d->widget->makeCurrent(); |
|
113 } |
|
114 |
|
115 QGLTemporaryContext::~QGLTemporaryContext() |
|
116 { |
|
117 delete d->widget; |
|
118 } |
100 |
119 |
101 /***************************************************************************** |
120 /***************************************************************************** |
102 QGLFormat Win32/WGL-specific code |
121 QGLFormat Win32/WGL-specific code |
103 *****************************************************************************/ |
122 *****************************************************************************/ |
104 |
123 |
134 } |
153 } |
135 |
154 |
136 // Get the display and initialize it. |
155 // Get the display and initialize it. |
137 d->eglContext = new QEglContext(); |
156 d->eglContext = new QEglContext(); |
138 d->eglContext->setApi(QEgl::OpenGL); |
157 d->eglContext->setApi(QEgl::OpenGL); |
139 if (!d->eglContext->openDisplay(device())) { |
|
140 delete d->eglContext; |
|
141 d->eglContext = 0; |
|
142 return false; |
|
143 } |
|
144 |
158 |
145 // Construct the configuration we need for this surface. |
159 // Construct the configuration we need for this surface. |
146 QEglProperties configProps; |
160 QEglProperties configProps; |
147 qt_egl_add_platform_config(configProps, device()); |
161 qt_egl_add_platform_config(configProps, device()); |
148 qt_egl_set_format(configProps, devType, d->glFormat); |
162 qt_egl_set_format(configProps, devType, d->glFormat); |
625 free(lpal); |
639 free(lpal); |
626 d->updateColormap(); |
640 d->updateColormap(); |
627 } |
641 } |
628 } |
642 } |
629 |
643 |
630 void QGLExtensions::init() |
|
631 { |
|
632 static bool init_done = false; |
|
633 |
|
634 if (init_done) |
|
635 return; |
|
636 init_done = true; |
|
637 |
|
638 // We need a context current to initialize the extensions. |
|
639 QGLWidget tmpWidget; |
|
640 tmpWidget.makeCurrent(); |
|
641 |
|
642 init_extensions(); |
|
643 |
|
644 tmpWidget.doneCurrent(); |
|
645 } |
|
646 |
|
647 QT_END_NAMESPACE |
644 QT_END_NAMESPACE |