VirtualBox

source: vbox/trunk/src/VBox/Main/generic/OpenGLTest.cpp@ 20500

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

Main/generic/Open*.cpp: license header fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.3 KB
Line 
1/* $Id: OpenGLTest.cpp 20500 2009-06-12 11:30:19Z vboxsync $ */
2/** @file
3 * VBox host opengl support test - generic implementation.
4 */
5
6/*
7 * Copyright (C) 2009 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include <VBox/err.h>
23#include <iprt/assert.h>
24#include <iprt/env.h>
25#include <iprt/param.h>
26#include <iprt/path.h>
27#include <iprt/process.h>
28#include <iprt/string.h>
29#include <iprt/time.h>
30
31bool is3DAccelerationSupported()
32{
33 static char pszVBoxPath[RTPATH_MAX];
34 const char *papszArgs[3] = { NULL, "-test", NULL};
35 int rc;
36 RTPROCESS Process;
37 RTPROCSTATUS ProcStatus;
38 uint64_t StartTS;
39
40 rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
41#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
42 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
43#else
44 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
45#endif
46 AssertRCReturn(rc, false);
47 papszArgs[0] = pszVBoxPath; /* argv[0] */
48
49 rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
50 if (RT_FAILURE(rc))
51 return false;
52
53 StartTS = RTTimeMilliTS();
54
55 while (1)
56 {
57 rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
58 if (rc != VERR_PROCESS_RUNNING)
59 break;
60
61 if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
62 {
63 RTProcTerminate(Process);
64 RTThreadSleep(100);
65 RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
66 return false;
67 }
68 RTThreadSleep(100);
69 }
70
71 if (RT_SUCCESS(rc))
72 {
73 if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
74 {
75 return true;
76 }
77 }
78
79 return false;
80}
81
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