1 | /* $Id: OpenGLTestApp.cpp 24005 2009-10-23 06:58:55Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox host opengl support test application.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009 Sun Microsystems, Inc.
|
---|
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 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #include <iprt/assert.h>
|
---|
23 | #include <iprt/buildconfig.h>
|
---|
24 | #include <iprt/err.h>
|
---|
25 | #include <iprt/getopt.h>
|
---|
26 | #include <iprt/initterm.h>
|
---|
27 | #include <iprt/stream.h>
|
---|
28 | #ifdef RT_OS_WINDOWS
|
---|
29 | #include <Windows.h>
|
---|
30 | #endif
|
---|
31 |
|
---|
32 | #include <string.h>
|
---|
33 |
|
---|
34 | #ifdef VBOX_WITH_CROGL
|
---|
35 |
|
---|
36 | extern "C" {
|
---|
37 | extern void * crSPULoad(void *, int, char *, char *, void *);
|
---|
38 | extern void crSPUUnloadChain(void *);
|
---|
39 | }
|
---|
40 |
|
---|
41 |
|
---|
42 | static int vboxCheck3DAccelerationSupported()
|
---|
43 | {
|
---|
44 | void *spu = crSPULoad(NULL, 0, (char*)"render", NULL, NULL);
|
---|
45 | if (spu)
|
---|
46 | {
|
---|
47 | crSPUUnloadChain(spu);
|
---|
48 | return 0;
|
---|
49 | }
|
---|
50 | return 1;
|
---|
51 | }
|
---|
52 | #endif
|
---|
53 |
|
---|
54 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
55 | #include <QGLWidget>
|
---|
56 | #include <QApplication>
|
---|
57 | #include <VBox/VBoxGL2D.h>
|
---|
58 |
|
---|
59 | static int vboxCheck2DVideoAccelerationSupported()
|
---|
60 | {
|
---|
61 | static int dummyArgc = 1;
|
---|
62 | static char * dummyArgv = (char*)"GlTest";
|
---|
63 | QApplication app (dummyArgc, &dummyArgv);
|
---|
64 |
|
---|
65 | VBoxGLTmpContext ctx;
|
---|
66 | const QGLContext *pContext = ctx.makeCurrent();
|
---|
67 | if(pContext)
|
---|
68 | {
|
---|
69 | VBoxVHWAInfo supportInfo;
|
---|
70 | supportInfo.init(pContext);
|
---|
71 | if(supportInfo.isVHWASupported())
|
---|
72 | return 0;
|
---|
73 | }
|
---|
74 | return 1;
|
---|
75 | }
|
---|
76 |
|
---|
77 | #endif
|
---|
78 |
|
---|
79 | int main(int argc, char **argv)
|
---|
80 | {
|
---|
81 | int rc=0;
|
---|
82 |
|
---|
83 | RTR3Init();
|
---|
84 |
|
---|
85 | if(argc < 2)
|
---|
86 | {
|
---|
87 | #ifdef VBOX_WITH_CROGL
|
---|
88 | /* backwards compatibility: check 3D */
|
---|
89 | rc = vboxCheck3DAccelerationSupported();
|
---|
90 | #endif
|
---|
91 | }
|
---|
92 | else
|
---|
93 | {
|
---|
94 | static const RTGETOPTDEF s_aOptionDefs[] =
|
---|
95 | {
|
---|
96 | { "--test", 't', RTGETOPT_REQ_STRING },
|
---|
97 | { "-test", 't', RTGETOPT_REQ_STRING },
|
---|
98 | { "--help", 'h', RTGETOPT_REQ_NOTHING },
|
---|
99 | };
|
---|
100 |
|
---|
101 | RTGETOPTSTATE State;
|
---|
102 | rc = RTGetOptInit(&State, argc-1, argv+1, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0);
|
---|
103 | AssertRCReturn(rc, 49);
|
---|
104 |
|
---|
105 | for (;;)
|
---|
106 | {
|
---|
107 | RTGETOPTUNION Val;
|
---|
108 | rc = RTGetOpt(&State, &Val);
|
---|
109 | if (!rc)
|
---|
110 | break;
|
---|
111 | switch (rc)
|
---|
112 | {
|
---|
113 | case 't':
|
---|
114 | #ifdef VBOX_WITH_CROGL
|
---|
115 | if (!strcmp(Val.psz, "3D") || !strcmp(Val.psz, "3d"))
|
---|
116 | {
|
---|
117 | rc = vboxCheck3DAccelerationSupported();
|
---|
118 | break;
|
---|
119 | }
|
---|
120 | #endif
|
---|
121 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
122 | if (!strcmp(Val.psz, "2D") || !strcmp(Val.psz, "2d"))
|
---|
123 | {
|
---|
124 | rc = vboxCheck2DVideoAccelerationSupported();
|
---|
125 | break;
|
---|
126 | }
|
---|
127 | #endif
|
---|
128 | rc = 1;
|
---|
129 | break;
|
---|
130 |
|
---|
131 | case 'h':
|
---|
132 | RTPrintf("VirtualBox Helper for testing 2D/3D OpenGL capabilities %u.%u.%u\n"
|
---|
133 | "(C) 2009 Sun Microsystems, Inc.\n"
|
---|
134 | "All rights reserved.\n"
|
---|
135 | "\n"
|
---|
136 | "Parameters:\n"
|
---|
137 | " --test 2D test for 2D (video) OpenGL capabilities\n"
|
---|
138 | " --test 3D test for 3D OpenGL capabilities\n"
|
---|
139 | "\n",
|
---|
140 | RTBldCfgVersionMajor(), RTBldCfgVersionMinor(), RTBldCfgVersionBuild());
|
---|
141 | break;
|
---|
142 |
|
---|
143 | case VERR_GETOPT_UNKNOWN_OPTION:
|
---|
144 | case VINF_GETOPT_NOT_OPTION:
|
---|
145 | rc = 1;
|
---|
146 |
|
---|
147 | default:
|
---|
148 | break;
|
---|
149 | }
|
---|
150 |
|
---|
151 | if(rc)
|
---|
152 | break;
|
---|
153 | }
|
---|
154 | }
|
---|
155 |
|
---|
156 | /*RTR3Term();*/
|
---|
157 | return rc;
|
---|
158 |
|
---|
159 | }
|
---|
160 |
|
---|
161 | #ifdef RT_OS_WINDOWS
|
---|
162 | extern "C" int WINAPI WinMain(HINSTANCE hInstance,
|
---|
163 | HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nShowCmd*/)
|
---|
164 | {
|
---|
165 | return main(__argc, __argv);
|
---|
166 | }
|
---|
167 | #endif
|
---|
168 |
|
---|