Enforce OpenGL context creation under Cocoa
We don't support other context types, so fail in those cases. Also, return OpenGL as the rendereable type of our surface. Change-Id: I3d5632eb8555d73ed14837b662c7450589a8681f Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
This commit is contained in:
parent
3b5600f6ee
commit
7e57501016
@ -61,6 +61,7 @@ void (*qcgl_getProcAddress(const QByteArray &procName))()
|
|||||||
QSurfaceFormat qcgl_surfaceFormat()
|
QSurfaceFormat qcgl_surfaceFormat()
|
||||||
{
|
{
|
||||||
QSurfaceFormat format;
|
QSurfaceFormat format;
|
||||||
|
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
format.setRedBufferSize(8);
|
format.setRedBufferSize(8);
|
||||||
format.setGreenBufferSize(8);
|
format.setGreenBufferSize(8);
|
||||||
format.setBlueBufferSize(8);
|
format.setBlueBufferSize(8);
|
||||||
|
@ -49,11 +49,19 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
|
QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
|
||||||
: m_format(format)
|
: m_context(nil),
|
||||||
|
m_shareContext(nil),
|
||||||
|
m_format(format)
|
||||||
{
|
{
|
||||||
|
// we only support OpenGL contexts under Cocoa
|
||||||
|
if (m_format.renderableType() == QSurfaceFormat::DefaultRenderableType)
|
||||||
|
m_format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||||
|
if (m_format.renderableType() != QSurfaceFormat::OpenGL)
|
||||||
|
return;
|
||||||
|
|
||||||
QCocoaAutoReleasePool pool; // For the SG Canvas render thread
|
QCocoaAutoReleasePool pool; // For the SG Canvas render thread
|
||||||
|
|
||||||
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(format));
|
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(m_format));
|
||||||
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
|
m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
|
||||||
|
|
||||||
m_context = [NSOpenGLContext alloc];
|
m_context = [NSOpenGLContext alloc];
|
||||||
|
Loading…
Reference in New Issue
Block a user