VirtualBox

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

Last change on this file since 28851 was 28800, checked in by vboxsync, 14 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.4 KB
Line 
1/* $Id: OpenGLTest.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * VBox host opengl support test - generic implementation.
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
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
18#include <VBox/err.h>
19#include <iprt/assert.h>
20#include <iprt/env.h>
21#include <iprt/param.h>
22#include <iprt/path.h>
23#include <iprt/process.h>
24#include <iprt/string.h>
25#include <iprt/time.h>
26#include <iprt/thread.h>
27
28bool is3DAccelerationSupported()
29{
30 static char pszVBoxPath[RTPATH_MAX];
31 const char *papszArgs[4] = { NULL, "-test", "3D", NULL};
32 int rc;
33 RTPROCESS Process;
34 RTPROCSTATUS ProcStatus;
35 uint64_t StartTS;
36
37 rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false);
38#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
39 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe");
40 static char pszVBoxPathArg[RTPATH_MAX];
41 pszVBoxPathArg[0] = '"';
42 strcpy(pszVBoxPathArg+1, pszVBoxPath);
43 char *pszPathEnd = (char *)memchr(pszVBoxPathArg, '\0', RTPATH_MAX);
44 pszPathEnd[0] = '"';
45 pszPathEnd[1] = '\0';
46 papszArgs[0] = pszVBoxPathArg; /* argv[0] */
47#else
48 rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL");
49 papszArgs[0] = pszVBoxPath; /* argv[0] */
50#endif
51 AssertRCReturn(rc, false);
52
53 rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process);
54 if (RT_FAILURE(rc))
55 return false;
56
57 StartTS = RTTimeMilliTS();
58
59 while (1)
60 {
61 rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
62 if (rc != VERR_PROCESS_RUNNING)
63 break;
64
65 if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */)
66 {
67 RTProcTerminate(Process);
68 RTThreadSleep(100);
69 RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
70 return false;
71 }
72 RTThreadSleep(100);
73 }
74
75 if (RT_SUCCESS(rc))
76 {
77 if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
78 {
79 return true;
80 }
81 }
82
83 return false;
84}
85
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