VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/OpenGLTest/OpenGLTestDarwin.cpp@ 41561

Last change on this file since 41561 was 40845, checked in by vboxsync, 13 years ago

3D check: direct invocation on the client side

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

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