1 | /* $Id: OpenGLTest.cpp 20300 2009-06-05 08:23:27Z vboxsync $ */
|
---|
2 |
|
---|
3 | /** @file
|
---|
4 | * VBox host opengl support test
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
9 | *
|
---|
10 | * Sun Microsystems, Inc. confidential
|
---|
11 | * All rights reserved
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include <VBox/err.h>
|
---|
15 | #include <iprt/process.h>
|
---|
16 | #include <iprt/path.h>
|
---|
17 | #include <iprt/param.h>
|
---|
18 | #include <iprt/env.h>
|
---|
19 | #include <iprt/thread.h>
|
---|
20 | #include <string.h>
|
---|
21 | #include <stdio.h>
|
---|
22 |
|
---|
23 | bool is3DAccelerationSupported()
|
---|
24 | {
|
---|
25 | static char pszVBoxPath[RTPATH_MAX];
|
---|
26 | const char *pArgs[2] = {"-test", NULL};
|
---|
27 | int rc;
|
---|
28 | RTPROCESS Process;
|
---|
29 | RTPROCSTATUS ProcStatus;
|
---|
30 | RTTIMESPEC Start;
|
---|
31 | RTTIMESPEC Now;
|
---|
32 |
|
---|
33 | RTProcGetExecutableName(pszVBoxPath, RTPATH_MAX);
|
---|
34 | RTPathStripFilename(pszVBoxPath);
|
---|
35 | strcat(pszVBoxPath,"/VBoxTestOGL");
|
---|
36 | #ifdef RT_OS_WINDOWS
|
---|
37 | strcat(pszVBoxPath,".exe");
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | rc = RTProcCreate(pszVBoxPath, pArgs, RTENV_DEFAULT, 0, &Process);
|
---|
41 | if (RT_FAILURE(rc)) return false;
|
---|
42 |
|
---|
43 | RTTimeNow(&Start);
|
---|
44 |
|
---|
45 | while (1)
|
---|
46 | {
|
---|
47 | rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
|
---|
48 | if (rc != VERR_PROCESS_RUNNING)
|
---|
49 | break;
|
---|
50 |
|
---|
51 | if (RTTimeSpecGetMilli(RTTimeSpecSub(RTTimeNow(&Now), &Start)) > 30*1000 /* 30 sec */)
|
---|
52 | {
|
---|
53 | RTProcTerminate(Process);
|
---|
54 | RTThreadSleep(100);
|
---|
55 | RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus);
|
---|
56 | return false;
|
---|
57 | }
|
---|
58 | RTThreadSleep(100);
|
---|
59 | }
|
---|
60 |
|
---|
61 | if (RT_SUCCESS(rc))
|
---|
62 | {
|
---|
63 | if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0))
|
---|
64 | {
|
---|
65 | return true;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | return false;
|
---|
70 | }
|
---|