From 14ee89c73b263c9a9e6e5bd300ef05c1ed41742a Mon Sep 17 00:00:00 2001 From: Michael Meskes Date: Thu, 20 Jan 2011 11:21:45 +0100 Subject: Imported Upstream version 4.0.2-dfsg --- src/VBox/Main/src-server/generic/OpenGLTest.cpp | 78 +++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 src/VBox/Main/src-server/generic/OpenGLTest.cpp (limited to 'src/VBox/Main/src-server/generic/OpenGLTest.cpp') diff --git a/src/VBox/Main/src-server/generic/OpenGLTest.cpp b/src/VBox/Main/src-server/generic/OpenGLTest.cpp new file mode 100644 index 000000000..efc68d1f4 --- /dev/null +++ b/src/VBox/Main/src-server/generic/OpenGLTest.cpp @@ -0,0 +1,78 @@ +/* $Id: OpenGLTest.cpp 29208 2010-05-07 13:09:51Z vboxsync $ */ +/** @file + * VBox host opengl support test - generic implementation. + */ + +/* + * Copyright (C) 2009 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +bool is3DAccelerationSupported() +{ + static char pszVBoxPath[RTPATH_MAX]; + const char *papszArgs[4] = { NULL, "-test", "3D", NULL}; + int rc; + RTPROCESS Process; + RTPROCSTATUS ProcStatus; + uint64_t StartTS; + + rc = RTPathExecDir(pszVBoxPath, RTPATH_MAX); AssertRCReturn(rc, false); +#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2) + rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL.exe"); +#else + rc = RTPathAppend(pszVBoxPath, RTPATH_MAX, "VBoxTestOGL"); +#endif + papszArgs[0] = pszVBoxPath; /* argv[0] */ + AssertRCReturn(rc, false); + + rc = RTProcCreate(pszVBoxPath, papszArgs, RTENV_DEFAULT, 0, &Process); + if (RT_FAILURE(rc)) + return false; + + StartTS = RTTimeMilliTS(); + + while (1) + { + rc = RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus); + if (rc != VERR_PROCESS_RUNNING) + break; + + if (RTTimeMilliTS() - StartTS > 30*1000 /* 30 sec */) + { + RTProcTerminate(Process); + RTThreadSleep(100); + RTProcWait(Process, RTPROCWAIT_FLAGS_NOBLOCK, &ProcStatus); + return false; + } + RTThreadSleep(100); + } + + if (RT_SUCCESS(rc)) + { + if ((ProcStatus.enmReason==RTPROCEXITREASON_NORMAL) && (ProcStatus.iStatus==0)) + { + return true; + } + } + + return false; +} + -- cgit v1.2.3