VirtualBox

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

Last change on this file since 25877 was 23384, checked in by vboxsync, 15 years ago

crOpenGL-OSX: check for the necessary OpenGL extensions on OSX

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1/* $Id: OpenGLTestDarwin.cpp 23384 2009-09-28 14:11:08Z 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#ifdef VBOX_WITH_COCOA_QT
28# include <OpenGL/glu.h>
29# include <iprt/log.h>
30#endif /* VBOX_WITH_COCOA_QT */
31
32bool is3DAccelerationSupported()
33{
34 CGDirectDisplayID display = CGMainDisplayID ();
35 CGOpenGLDisplayMask cglDisplayMask = CGDisplayIDToOpenGLDisplayMask (display);
36 CGLPixelFormatObj pixelFormat = NULL;
37 GLint numPixelFormats = 0;
38
39 CGLPixelFormatAttribute attribs[] = {
40 kCGLPFADisplayMask,
41 (CGLPixelFormatAttribute)cglDisplayMask,
42 kCGLPFAAccelerated,
43 kCGLPFADoubleBuffer,
44 kCGLPFAWindow,
45 (CGLPixelFormatAttribute)NULL
46 };
47
48 display = CGMainDisplayID();
49 cglDisplayMask = CGDisplayIDToOpenGLDisplayMask(display);
50 CGLChoosePixelFormat(attribs, &pixelFormat, &numPixelFormats);
51
52 if (pixelFormat)
53 {
54 CGLContextObj cglContext = 0;
55 CGLCreateContext(pixelFormat, NULL, &cglContext);
56 CGLDestroyPixelFormat(pixelFormat);
57 if (cglContext)
58 {
59 GLboolean isSupported = GL_TRUE;
60#ifdef VBOX_WITH_COCOA_QT
61 /* On the Cocoa port we depend on the GL_EXT_framebuffer_object &
62 * the GL_EXT_texture_rectangle extension. If they are not
63 * available, disable 3D support. */
64 CGLSetCurrentContext(cglContext);
65 const GLubyte* strExt;
66 strExt = glGetString(GL_EXTENSIONS);
67 isSupported = gluCheckExtension((const GLubyte*)"GL_EXT_framebuffer_object", strExt);
68 if (isSupported)
69 {
70 isSupported = gluCheckExtension((const GLubyte*)"GL_EXT_texture_rectangle", strExt);
71 if (!isSupported)
72 LogRel(("OpenGL Info: GL_EXT_texture_rectangle extension not supported\n"));
73 }
74 else
75 LogRel(("OpenGL Info: GL_EXT_framebuffer_object extension not supported\n"));
76#endif /* VBOX_WITH_COCOA_QT */
77 CGLDestroyContext(cglContext);
78 return isSupported == GL_TRUE ? true : false;
79 }
80 }
81
82 return false;
83}
84
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