1 | /* $Id: OpenGLTestDarwin.cpp 20161 2009-05-29 16:30:42Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox host opengl support test
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * Sun Microsystems, Inc. confidential
|
---|
11 | * All rights reserved
|
---|
12 | */
|
---|
13 |
|
---|
14 |
|
---|
15 | #include <OpenGL/OpenGL.h>
|
---|
16 | #include <ApplicationServices/ApplicationServices.h>
|
---|
17 |
|
---|
18 | bool is3DAccelerationSupported()
|
---|
19 | {
|
---|
20 | CGDirectDisplayID display = CGMainDisplayID ();
|
---|
21 | CGOpenGLDisplayMask cglDisplayMask = CGDisplayIDToOpenGLDisplayMask (display);
|
---|
22 | CGLPixelFormatObj pixelFormat = NULL;
|
---|
23 | GLint numPixelFormats = 0;
|
---|
24 |
|
---|
25 | CGLPixelFormatAttribute attribs[] = {
|
---|
26 | kCGLPFADisplayMask,
|
---|
27 | (CGLPixelFormatAttribute)cglDisplayMask,
|
---|
28 | kCGLPFAAccelerated,
|
---|
29 | kCGLPFADoubleBuffer,
|
---|
30 | kCGLPFAWindow,
|
---|
31 | (CGLPixelFormatAttribute)NULL
|
---|
32 | };
|
---|
33 |
|
---|
34 | display = CGMainDisplayID();
|
---|
35 | cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(display);
|
---|
36 | CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats);
|
---|
37 |
|
---|
38 | if (pixelFormat)
|
---|
39 | {
|
---|
40 | CGLContextObj cglContext = 0;
|
---|
41 | CGLCreateContext(pixelFormat, NULL, &cglContext);
|
---|
42 | CGLDestroyPixelFormat(pixelFormat);
|
---|
43 | if (cglContext)
|
---|
44 | {
|
---|
45 | CGLDestroyContext(cglContext);
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 | }
|
---|
49 |
|
---|
50 | return false;
|
---|
51 | }
|
---|
52 |
|
---|