~ubuntu-branches/ubuntu/raring/virtualbox-ose/raring

« back to all changes in this revision

Viewing changes to src/VBox/Main/src-server/darwin/OpenGLTestDarwin.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Felix Geyer
  • Date: 2011-01-30 23:27:25 UTC
  • mfrom: (0.3.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20110130232725-2ouajjd2ggdet0zd
Tags: 4.0.2-dfsg-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add Apport hook.
    - debian/virtualbox-ose.files/source_virtualbox-ose.py
    - debian/virtualbox-ose.install
  - Drop *-source packages.
* Drop ubuntu-01-fix-build-gcc45.patch, fixed upstream.
* Drop ubuntu-02-as-needed.patch, added to the Debian package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
28
bool 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