Changeset 651 for trunk/src/opengl/qgl_mac.mm
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/src/opengl/qgl_mac.mm
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 116 116 extern QRegion qt_mac_convert_mac_region(RgnHandle); //qregion_mac.cpp 117 117 extern void qt_mac_to_pascal_string(QString s, Str255 str, TextEncoding encoding=0, int len=-1); //qglobal.cpp 118 119 /* 120 QGLTemporaryContext implementation 121 */ 122 123 class QGLTemporaryContextPrivate 124 { 125 public: 126 #ifndef QT_MAC_USE_COCOA 127 AGLContext ctx; 128 #else 129 NSOpenGLContext *ctx; 130 #endif 131 }; 132 133 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *) 134 : d(new QGLTemporaryContextPrivate) 135 { 136 d->ctx = 0; 137 #ifndef QT_MAC_USE_COCOA 138 GLint attribs[] = {AGL_RGBA, AGL_NONE}; 139 AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs); 140 if (!fmt) { 141 qDebug("QGLTemporaryContext: Couldn't find any RGB visuals"); 142 return; 143 } 144 d->ctx = aglCreateContext(fmt, 0); 145 if (!d->ctx) 146 qDebug("QGLTemporaryContext: Unable to create context"); 147 else 148 aglSetCurrentContext(d->ctx); 149 aglDestroyPixelFormat(fmt); 150 #else 151 QMacCocoaAutoReleasePool pool; 152 NSOpenGLPixelFormatAttribute attribs[] = { 0 }; 153 NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; 154 if (!fmt) { 155 qWarning("QGLTemporaryContext: Cannot find any visuals"); 156 return; 157 } 158 159 d->ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:0]; 160 if (!d->ctx) 161 qWarning("QGLTemporaryContext: Cannot create context"); 162 else 163 [d->ctx makeCurrentContext]; 164 [fmt release]; 165 #endif 166 } 167 168 QGLTemporaryContext::~QGLTemporaryContext() 169 { 170 if (d->ctx) { 171 #ifndef QT_MAC_USE_COCOA 172 aglSetCurrentContext(0); 173 aglDestroyContext(d->ctx); 174 #else 175 [NSOpenGLContext clearCurrentContext]; 176 [d->ctx release]; 177 #endif 178 } 179 } 118 180 119 181 bool QGLFormat::hasOpenGL() … … 477 539 d->transpColor = QColor(); 478 540 d->initDone = false; 479 qgl_share_reg()->removeShare(this);541 QGLContextGroup::removeShare(this); 480 542 } 481 543 … … 607 669 } 608 670 } else if (d->paintDevice->devType() == QInternal::Pixmap) { 609 QPixmap *pm = (QPixmap *)d->paintDevice; 610 PixMapHandle mac_pm = GetGWorldPixMap((GWorldPtr)pm->macQDHandle()); 611 aglSetOffScreen((AGLContext)d->cx, pm->width(), pm->height(), 612 GetPixRowBytes(mac_pm), GetPixBaseAddr(mac_pm)); 671 QPixmap *pm = reinterpret_cast<QPixmap *>(d->paintDevice); 672 673 unsigned long qdformat = k32ARGBPixelFormat; 674 if (QSysInfo::ByteOrder == QSysInfo::LittleEndian) 675 qdformat = k32BGRAPixelFormat; 676 Rect rect; 677 SetRect(&rect, 0, 0, pm->width(), pm->height()); 678 679 GWorldPtr gworld; 680 NewGWorldFromPtr(&gworld, qdformat, &rect, 0, 0, 0, 681 reinterpret_cast<char *>(qt_mac_pixmap_get_base(pm)), 682 qt_mac_pixmap_get_bytes_per_line(pm)); 683 684 PixMapHandle pixmapHandle = GetGWorldPixMap(gworld); 685 aglSetOffScreen(reinterpret_cast<AGLContext>(d->cx), pm->width(), pm->height(), 686 GetPixRowBytes(pixmapHandle), GetPixBaseAddr(pixmapHandle)); 613 687 } else { 614 688 qWarning("QGLContext::updatePaintDevice(): Not sure how to render OpenGL on this device!"); … … 907 981 } 908 982 909 910 void QGLExtensions::init()911 {912 static bool init_done = false;913 914 if (init_done)915 return;916 init_done = true;917 918 #ifndef QT_MAC_USE_COCOA919 GLint attribs[] = { AGL_RGBA, AGL_NONE };920 AGLPixelFormat fmt = aglChoosePixelFormat(0, 0, attribs);921 if (!fmt) {922 qDebug("QGLExtensions: Couldn't find any RGB visuals");923 return;924 }925 AGLContext ctx = aglCreateContext(fmt, 0);926 if (!ctx) {927 qDebug("QGLExtensions: Unable to create context");928 } else {929 aglSetCurrentContext(ctx);930 init_extensions();931 aglSetCurrentContext(0);932 aglDestroyContext(ctx);933 }934 aglDestroyPixelFormat(fmt);935 #else936 QMacCocoaAutoReleasePool pool;937 NSOpenGLPixelFormatAttribute attribs[] = { 0 };938 NSOpenGLPixelFormat *fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];939 if (!fmt) {940 qWarning("QGLExtensions: Cannot find any visuals");941 return;942 }943 944 NSOpenGLContext *ctx = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:0];945 if (!ctx) {946 qWarning("QGLExtensions: Cannot create context");947 } else {948 [ctx makeCurrentContext];949 init_extensions();950 [NSOpenGLContext clearCurrentContext];951 [ctx release];952 }953 [fmt release];954 #endif955 }956 957 983 #endif 958 984
Note:
See TracChangeset
for help on using the changeset viewer.