1
/* $Id: OpenGLTestDarwin.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
4
* VBox host opengl support test
8
* Copyright (C) 2009 Oracle Corporation
10
* This file is part of VirtualBox Open Source Edition (OSE), as
11
* available from http://www.virtualbox.org. This file is free software;
12
* you can redistribute it and/or modify it under the terms of the GNU
13
* General Public License (GPL) as published by the Free Software
14
* Foundation, in version 2 as it comes in the "COPYING" file of the
15
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
#include <OpenGL/OpenGL.h>
21
#include <ApplicationServices/ApplicationServices.h>
22
#include <OpenGL/gl.h>
23
#ifdef VBOX_WITH_COCOA_QT
24
# include <OpenGL/glu.h>
25
# include <iprt/log.h>
26
#endif /* VBOX_WITH_COCOA_QT */
28
bool is3DAccelerationSupported()
30
CGDirectDisplayID display = CGMainDisplayID ();
31
CGOpenGLDisplayMask cglDisplayMask = CGDisplayIDToOpenGLDisplayMask (display);
32
CGLPixelFormatObj pixelFormat = NULL;
33
GLint numPixelFormats = 0;
35
CGLPixelFormatAttribute attribs[] = {
37
(CGLPixelFormatAttribute)cglDisplayMask,
41
(CGLPixelFormatAttribute)NULL
44
display = CGMainDisplayID();
45
cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(display);
46
CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats);
50
CGLContextObj cglContext = 0;
51
CGLCreateContext(pixelFormat, NULL, &cglContext);
52
CGLDestroyPixelFormat(pixelFormat);
55
GLboolean isSupported = GL_TRUE;
56
#ifdef VBOX_WITH_COCOA_QT
57
/* On the Cocoa port we depend on the GL_EXT_framebuffer_object &
58
* the GL_EXT_texture_rectangle extension. If they are not
59
* available, disable 3D support. */
60
CGLSetCurrentContext(cglContext);
61
const GLubyte* strExt;
62
strExt = glGetString(GL_EXTENSIONS);
63
isSupported = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", strExt);
66
isSupported = gluCheckExtension((const GLubyte*)"GL_EXT_texture_rectangle", strExt);
68
LogRel(("OpenGL Info: GL_EXT_texture_rectangle extension not supported\n"));
71
LogRel(("OpenGL Info: GL_EXT_framebuffer_object extension not supported\n"));
72
#endif /* VBOX_WITH_COCOA_QT */
73
CGLDestroyContext(cglContext);
74
return isSupported == GL_TRUE ? true : false;