OpenGLTestApp.cpp revision 7012c4fe33d74bb65f08a9eae37a49467efcec56
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/* $Id$ */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/** @file
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync * VBox host opengl support test application.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync/*
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync * Copyright (C) 2009 Sun Microsystems, Inc.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * available from http://www.virtualbox.org. This file is free software;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * you can redistribute it and/or modify it under the terms of the GNU
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * General Public License (GPL) as published by the Free Software
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync *
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync * additional information or have any questions.
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync */
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/assert.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/buildconfig.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/err.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/getopt.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/initterm.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#include <iprt/stream.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef RT_OS_WINDOWS
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync# include <Windows.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include <sys/resource.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include <fcntl.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync# include <unistd.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#include <string.h>
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#define VBOXGLTEST_WITH_LOGGING
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef VBOXGLTEST_WITH_LOGGING
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#include "package-generated.h"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/log.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/param.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/time.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/system.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/process.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <iprt/env.h>
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#include <VBox/log.h>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#include <VBox/version.h>
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync#endif
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef VBOX_WITH_CROGL
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsyncextern "C"
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync{
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync extern void * crSPULoad(void *, int, char *, char *, void *);
c89333d3e41e439ed9e74768000edc399d3e72e6vboxsync extern void crSPUUnloadChain(void *);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic int vboxCheck3DAccelerationSupported()
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("Testing 3D Support:\n"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync void *spu = crSPULoad(NULL, 0, (char*)"render", NULL, NULL);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (spu)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync crSPUUnloadChain(spu);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("Testing 3D Succeeded!\n"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("Testing 3D Failed\n"));
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync return 1;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync}
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#endif
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <QGLWidget>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <QApplication>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync#include <VBox/VBoxGL2D.h>
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsyncstatic int vboxCheck2DVideoAccelerationSupported()
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync{
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync LogRel(("Testing 2D Support:\n"));
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync static int dummyArgc = 1;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync static char * dummyArgv = (char*)"GlTest";
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync QApplication app (dummyArgc, &dummyArgv);
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync VBoxGLTmpContext ctx;
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync const QGLContext *pContext = ctx.makeCurrent();
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync if(pContext)
750df3fe104e01cadbc3d5bd20243055d283d4e5vboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBoxVHWAInfo supportInfo;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync supportInfo.init(pContext);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if(supportInfo.isVHWASupported())
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("Testing 2D Succeeded!\n"));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync LogRel(("Failed to create gl context\n"));
ffb50166c9adb4ae583b914d405197035cf890advboxsync }
ffb50166c9adb4ae583b914d405197035cf890advboxsync LogRel(("Testing 2D Failed\n"));
ffb50166c9adb4ae583b914d405197035cf890advboxsync return 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
ffb50166c9adb4ae583b914d405197035cf890advboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXGLTEST_WITH_LOGGING
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncstatic int vboxInitLogging(const char *pszFilename)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync PRTLOGGER loggerRelease;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTUINT fFlags = RTLOGFLAGS_PREFIX_TIME_PROG;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync fFlags |= RTLOGFLAGS_USECRLF;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync char szError[RTPATH_MAX + 128] = "";
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync const char * pszFilenameFmt;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLOGDEST enmLogDest;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if(pszFilename)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pszFilenameFmt = "%s";
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync enmLogDest = RTLOGDEST_FILE;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pszFilenameFmt = NULL;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync enmLogDest = RTLOGDEST_STDOUT;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync int vrc = RTLogCreateEx(&loggerRelease, fFlags, "all",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "VBOX_RELEASE_LOG", RT_ELEMENTS(s_apszGroups), s_apszGroups,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLOGDEST_FILE, szError, sizeof(szError), pszFilenameFmt, pszFilename);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(vrc))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync /* some introductory information */
248c89033c87fed7229aa29bbbc4f4698fb13687vboxsync RTTIMESPEC timeSpec;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync char szTmp[256];
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTTimeSpecToString(RTTimeNow(&timeSpec), szTmp, sizeof(szTmp));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLogRelLogger(loggerRelease, 0, ~0U,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "VBoxTestGL %s r%u %s (%s %s) release log\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_BLEEDING_EDGE
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "EXPERIMENTAL build " VBOX_BLEEDING_EDGE "\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "Log opened %s\n",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync VBOX_VERSION_STRING, RTBldCfgRevision(), VBOX_BUILD_TARGET,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync __DATE__, __TIME__, szTmp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vrc = RTSystemQueryOSInfo(RTSYSOSINFO_PRODUCT, szTmp, sizeof(szTmp));
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync RTLogRelLogger(loggerRelease, 0, ~0U, "OS Product: %s\n", szTmp);
b4d7b4dbcc45b8bde7502aa129440d92d7ffd038vboxsync vrc = RTSystemQueryOSInfo(RTSYSOSINFO_RELEASE, szTmp, sizeof(szTmp));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLogRelLogger(loggerRelease, 0, ~0U, "OS Release: %s\n", szTmp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vrc = RTSystemQueryOSInfo(RTSYSOSINFO_VERSION, szTmp, sizeof(szTmp));
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTLogRelLogger(loggerRelease, 0, ~0U, "OS Version: %s\n", szTmp);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync vrc = RTSystemQueryOSInfo(RTSYSOSINFO_SERVICE_PACK, szTmp, sizeof(szTmp));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (RT_SUCCESS(vrc) || vrc == VERR_BUFFER_OVERFLOW)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync RTLogRelLogger(loggerRelease, 0, ~0U, "OS Service Pack: %s\n", szTmp);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync// RTLogRelLogger(loggerRelease, 0, ~0U, "Host RAM: %uMB RAM, available: %uMB\n",
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync// uHostRamMb, uHostRamAvailMb);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* the package type is interesting for Linux distributions */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync char szExecName[RTPATH_MAX];
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync char *pszExecName = RTProcGetExecutableName(szExecName, sizeof(szExecName));
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync RTLogRelLogger(loggerRelease, 0, ~0U,
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync "Executable: %s\n"
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync "Process ID: %u\n"
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync "Package type: %s"
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#ifdef VBOX_OSE
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync " (OSE)"
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#endif
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync "\n",
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync pszExecName ? pszExecName : "unknown",
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync RTProcSelf(),
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync VBOX_PACKAGE_STRING);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* register this logger as the release logger */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync RTLogRelSetDefaultInstance(loggerRelease);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync }
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return vrc;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync}
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync#endif
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsyncstatic int vboxInitQuietMode()
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync{
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* This small test application might crash on some hosts. Do never
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * generate a core dump as most likely some OpenGL library is
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync * responsible. */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync struct rlimit lim = { 0, 0 };
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync setrlimit(RLIMIT_CORE, &lim);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync /* Redirect stderr to /dev/null */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync int fd = open("/dev/null", O_WRONLY);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if (fd != -1)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync dup2(fd, STDERR_FILENO);
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#endif
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync return 0;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync}
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsyncint main(int argc, char **argv)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync{
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync int rc = 0;
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync RTR3Init();
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync if(argc < 2)
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync {
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#ifdef VBOX_WITH_CROGL
3fb3de312d1ff675e0f7cc62a7d46cbb1d5d9353vboxsync /* backwards compatibility: check 3D */
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync rc = vboxCheck3DAccelerationSupported();
462e60a19d02a99b2b1a5c08dff74bb0808d707cvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync else
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync {
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync static const RTGETOPTDEF s_aOptionDefs[] =
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { "--test", 't', RTGETOPT_REQ_STRING },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { "-test", 't', RTGETOPT_REQ_STRING },
11b175175a0ed424b8e8354acda681ad0adde0f8vboxsync#ifdef VBOXGLTEST_WITH_LOGGING
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { "--log", 'l', RTGETOPT_REQ_STRING },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync { "--help", 'h', RTGETOPT_REQ_NOTHING },
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync };
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTGETOPTSTATE State;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = RTGetOptInit(&State, argc-1, argv+1, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync AssertRCReturn(rc, 49);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bool bTest2D = false;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_CROGL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bool bTest3D = false;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXGLTEST_WITH_LOGGING
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bool bLog = false;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync const char * pLog;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync for (;;)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTGETOPTUNION Val;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = RTGetOpt(&State, &Val);
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!rc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync switch (rc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 't':
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_CROGL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!strcmp(Val.psz, "3D") || !strcmp(Val.psz, "3d"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bTest3D = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if (!strcmp(Val.psz, "2D") || !strcmp(Val.psz, "2d"))
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bTest2D = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXGLTEST_WITH_LOGGING
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 'l':
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bLog = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync pLog = Val.psz;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = 0;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case 'h':
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTPrintf("VirtualBox Helper for testing 2D/3D OpenGL capabilities %u.%u.%u\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "(C) 2009 Sun Microsystems, Inc.\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "All rights reserved.\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "Parameters:\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync " --test 2D test for 2D (video) OpenGL capabilities\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOX_WITH_CROGL
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync " --test 3D test for 3D OpenGL capabilities\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXGLTEST_WITH_LOGGING
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync " --log <log_file_name> log the GL test result to the given file\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "Logging can alternatively be enabled by specifying the VBOXGLTEST_LOG=<log_file_name> env variable\n"
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync "\n",
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync RTBldCfgVersionMajor(), RTBldCfgVersionMinor(), RTBldCfgVersionBuild());
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case VERR_GETOPT_UNKNOWN_OPTION:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync case VINF_GETOPT_NOT_OPTION:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = 1;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync default:
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if(rc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync break;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync if(!rc)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef VBOXGLTEST_WITH_LOGGING
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if(!bLog)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync {
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /* check the VBOXGLTEST_LOG env var */
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync pLog = RTEnvGet("VBOXGLTEST_LOG");
cd5df721f068659172f3bf95de8fedeb465f057dvboxsync if(pLog)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync bLog = true;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if(bLog)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = vboxInitLogging(pLog);
b8bb9c9f6b8ebfd0a7d6df0c0289f9fe80241750vboxsync else
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#endif
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = vboxInitQuietMode();
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#ifdef VBOX_WITH_CROGL
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if(!rc && bTest3D)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync rc = vboxCheck3DAccelerationSupported();
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#endif
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#ifdef VBOX_WITH_VIDEOHWACCEL
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if(!rc && bTest2D)
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync rc = vboxCheck2DVideoAccelerationSupported();
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#endif
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync /*RTR3Term();*/
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return rc;
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync}
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync#ifdef RT_OS_WINDOWS
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsyncextern "C" int WINAPI WinMain(HINSTANCE hInstance,
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nShowCmd*/)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync{
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync return main(__argc, __argv);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync}
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync#endif
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync
553a2f0d8ef91a6dad8de4eef206ff093af53a5dvboxsync