VirtualBox

source: vbox/trunk/src/VBox/Main/darwin/OpenGLTestDarwin.cpp@ 22663

Last change on this file since 22663 was 20512, checked in by vboxsync, 16 years ago

OSE headers

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/* $Id: OpenGLTestDarwin.cpp 20512 2009-06-12 13:02:29Z vboxsync $ */
2
3/** @file
4 * VBox host opengl support test
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
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.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23
24#include <OpenGL/OpenGL.h>
25#include <ApplicationServices/ApplicationServices.h>
26#include <OpenGL/gl.h>
27
28bool is3DAccelerationSupported()
29{
30 CGDirectDisplayID display = CGMainDisplayID ();
31 CGOpenGLDisplayMask cglDisplayMask = CGDisplayIDToOpenGLDisplayMask (display);
32 CGLPixelFormatObj pixelFormat = NULL;
33 GLint numPixelFormats = 0;
34
35 CGLPixelFormatAttribute attribs[] = {
36 kCGLPFADisplayMask,
37 (CGLPixelFormatAttribute)cglDisplayMask,
38 kCGLPFAAccelerated,
39 kCGLPFADoubleBuffer,
40 kCGLPFAWindow,
41 (CGLPixelFormatAttribute)NULL
42 };
43
44 display = CGMainDisplayID();
45 cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(display);
46 CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats);
47
48 if (pixelFormat)
49 {
50 CGLContextObj cglContext = 0;
51 CGLCreateContext(pixelFormat, NULL, &cglContext);
52 CGLDestroyPixelFormat(pixelFormat);
53 if (cglContext)
54 {
55 CGLDestroyContext(cglContext);
56 return true;
57 }
58 }
59
60 return false;
61}
62
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette