OpenGLTestApp.cpp revision 2dd5cbbdf946ef2acea2c5150cfdf6f8203821c1
/* $Id$ */
/** @file
* VBox host opengl support test application.
*/
/*
* Copyright (C) 2009-2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* 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 <iprt/buildconfig.h>
#include <iprt/initterm.h>
#ifdef RT_OS_WINDOWS
# include <Windows.h>
#endif
#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
# include <sys/resource.h>
# include <fcntl.h>
# include <unistd.h>
#endif
#include <string.h>
#define VBOXGLTEST_WITH_LOGGING
#ifdef VBOXGLTEST_WITH_LOGGING
#include "package-generated.h"
#endif
#ifdef VBOX_WITH_CROGL
extern "C"
{
extern void * crSPULoad(void *, int, char *, char *, void *);
extern void crSPUUnloadChain(void *);
}
static int vboxCheck3DAccelerationSupported()
{
LogRel(("Testing 3D Support:\n"));
if (spu)
{
LogRel(("Testing 3D Succeeded!\n"));
return 0;
}
LogRel(("Testing 3D Failed\n"));
return 1;
}
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
#include <QGLWidget>
#include <QApplication>
#include <VBox/VBoxGL2D.h>
static int vboxCheck2DVideoAccelerationSupported()
{
LogRel(("Testing 2D Support:\n"));
static int dummyArgc = 1;
static char * dummyArgv = (char*)"GlTest";
if(pContext)
{
if(supportInfo.isVHWASupported())
{
LogRel(("Testing 2D Succeeded!\n"));
return 0;
}
}
else
{
LogRel(("Failed to create gl context\n"));
}
LogRel(("Testing 2D Failed\n"));
return 1;
}
#endif
#ifdef VBOXGLTEST_WITH_LOGGING
{
static const char * const s_apszGroups[] = VBOX_LOGGROUP_NAMES;
#if defined(RT_OS_WINDOWS) || defined(RT_OS_OS2)
#endif
const char * pszFilenameFmt;
if(pszFilename)
{
if(bGenNameSuffix)
pszFilenameFmt = "%s.%ld.log";
else
pszFilenameFmt = "%s";
}
else
{
}
if (RT_SUCCESS(vrc))
{
/* some introductory information */
char szTmp[256];
RTLogRelLogger(loggerRelease, 0, ~0U,
"VBoxTestGL %s r%u %s (%s %s) release log\n"
#ifdef VBOX_BLEEDING_EDGE
#endif
"Log opened %s\n",
// RTLogRelLogger(loggerRelease, 0, ~0U, "Host RAM: %uMB RAM, available: %uMB\n",
// uHostRamMb, uHostRamAvailMb);
/* the package type is interesting for Linux distributions */
char szExecName[RTPATH_MAX];
RTLogRelLogger(loggerRelease, 0, ~0U,
"Executable: %s\n"
"Process ID: %u\n"
"Package type: %s"
#ifdef VBOX_OSE
" (OSE)"
#endif
"\n",
RTProcSelf(),
/* register this logger as the release logger */
return VINF_SUCCESS;
}
return vrc;
}
#endif
static int vboxInitQuietMode()
{
#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_OS2)
/* This small test application might crash on some hosts. Do never
* generate a core dump as most likely some OpenGL library is
* responsible. */
if (fd != -1)
#endif
return 0;
}
{
int rc = 0;
if(argc < 2)
{
#ifdef VBOX_WITH_CROGL
/* backwards compatibility: check 3D */
#endif
}
else
{
static const RTGETOPTDEF s_aOptionDefs[] =
{
#ifdef VBOXGLTEST_WITH_LOGGING
#endif
};
#ifdef VBOX_WITH_VIDEOHWACCEL
bool bTest2D = false;
#endif
#ifdef VBOX_WITH_CROGL
bool bTest3D = false;
#endif
#ifdef VBOXGLTEST_WITH_LOGGING
bool bLog = false;
bool bLogSuffix = false;
#endif
for (;;)
{
if (!rc)
break;
switch (rc)
{
case 't':
#ifdef VBOX_WITH_CROGL
{
bTest3D = true;
rc = 0;
break;
}
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
{
bTest2D = true;
rc = 0;
break;
}
#endif
rc = 1;
break;
#ifdef VBOXGLTEST_WITH_LOGGING
case 'l':
bLog = true;
rc = 0;
break;
#endif
case 'h':
"All rights reserved.\n"
"\n"
"Parameters:\n"
#ifdef VBOX_WITH_VIDEOHWACCEL
" --test 2D test for 2D (video) OpenGL capabilities\n"
#endif
#ifdef VBOX_WITH_CROGL
" --test 3D test for 3D OpenGL capabilities\n"
#endif
#ifdef VBOXGLTEST_WITH_LOGGING
" --log <log_file_name> log the GL test result to the given file\n"
"\n"
"Logging can alternatively be enabled by specifying the VBOXGLTEST_LOG=<log_file_name> env variable\n"
#endif
"\n",
break;
case 'V':
RTPrintf("$Revision: $\n");
return 0;
case VINF_GETOPT_NOT_OPTION:
rc = 1;
default:
/* complain? RTGetOptPrintError(rc, &Val); */
break;
}
if (rc)
break;
}
if(!rc)
{
#ifdef VBOXGLTEST_WITH_LOGGING
if(!bLog)
{
/* check the VBOXGLTEST_LOG env var */
if(pLog)
bLog = true;
bLogSuffix = true;
}
if(bLog)
else
#endif
rc = vboxInitQuietMode();
#ifdef VBOX_WITH_CROGL
#endif
#ifdef VBOX_WITH_VIDEOHWACCEL
#endif
}
}
/*RTR3Term();*/
return rc;
}
#ifdef RT_OS_WINDOWS
{
}
#endif