VirtualBox

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

Last change on this file since 31651 was 28800, checked in by vboxsync, 15 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.7 KB
Line 
1/* $Id: OpenGLTestDarwin.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2
3/** @file
4 * VBox host opengl support test
5 */
6
7/*
8 * Copyright (C) 2009 Oracle Corporation
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
19
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 */
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 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);
64 if (isSupported)
65 {
66 isSupported = gluCheckExtension((const GLubyte*)"GL_EXT_texture_rectangle", strExt);
67 if (!isSupported)
68 LogRel(("OpenGL Info: GL_EXT_texture_rectangle extension not supported\n"));
69 }
70 else
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;
75 }
76 }
77
78 return false;
79}
80
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