VirtualBox

source: vbox/trunk/src/VBox/Main/generic/OpenGLTestApp.cpp@ 23803

Last change on this file since 23803 was 23748, checked in by vboxsync, 16 years ago

gl support test app fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.6 KB
Line 
1/* $Id: OpenGLTestApp.cpp 23748 2009-10-14 08:49:02Z 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/initterm.h>
23#include <iprt/getopt.h>
24#include <iprt/err.h>
25#include <iprt/assert.h>
26#ifdef RT_OS_WINDOWS
27#include <Windows.h>
28#endif
29
30#include <string>
31
32#ifdef VBOX_WITH_CROGL
33
34extern "C" {
35 extern void * crSPULoad(void *, int, char *, char *, void *);
36 extern void crSPUUnloadChain(void *);
37}
38
39
40static int vboxCheck3DAccelerationSupported()
41{
42 void *spu = crSPULoad(NULL, 0, "render", NULL, NULL);
43 if (spu)
44 {
45 crSPUUnloadChain(spu);
46 return 0;
47 }
48 return 1;
49}
50#endif
51
52#ifdef VBOX_WITH_VIDEOHWACCEL
53#include <QGLWidget>
54#include <QApplication>
55#include <VBox/VBoxGL2D.h>
56
57static int vboxCheck2DVideoAccelerationSupported()
58{
59 static int dummyArgc = 1;
60 static char * dummyArgv = "GlTest";
61 QApplication app (dummyArgc, &dummyArgv);
62
63 VBoxGLTmpContext ctx;
64 const QGLContext *pContext = ctx.makeCurrent();
65 if(pContext)
66 {
67 VBoxVHWAInfo supportInfo;
68 supportInfo.init(pContext);
69 if(supportInfo.isVHWASupported())
70 return 0;
71 }
72 return 1;
73}
74
75#endif
76
77int main(int argc, char **argv)
78{
79 int rc=0;
80
81 RTR3Init();
82
83 if(argc < 3)
84 {
85#ifdef VBOX_WITH_CROGL
86 /* backwards compatibility: check 3D */
87 rc = vboxCheck3DAccelerationSupported();
88#endif
89 }
90 else
91 {
92 static const RTGETOPTDEF s_aOptionDefs[] =
93 {
94 { "--test", 't', RTGETOPT_REQ_STRING },
95 { "-test", 't', RTGETOPT_REQ_STRING },
96 };
97
98 RTGETOPTSTATE State;
99 rc = RTGetOptInit(&State, argc-1, argv+1, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0);
100 AssertRCReturn(rc, 49);
101
102 for (;;)
103 {
104 RTGETOPTUNION Val;
105 rc = RTGetOpt(&State, &Val);
106 if (!rc)
107 break;
108 switch (rc)
109 {
110 case 't':
111#ifdef VBOX_WITH_CROGL
112 if (!strcmp(Val.psz, "3D") || !strcmp(Val.psz, "3d"))
113 {
114 rc = vboxCheck3DAccelerationSupported();
115 break;
116 }
117#endif
118#ifdef VBOX_WITH_VIDEOHWACCEL
119 if (!strcmp(Val.psz, "2D") || !strcmp(Val.psz, "2d"))
120 {
121 rc = vboxCheck2DVideoAccelerationSupported();
122 break;
123 }
124#endif
125 rc = 1;
126 break;
127 case VERR_GETOPT_UNKNOWN_OPTION:
128 case VINF_GETOPT_NOT_OPTION:
129 rc = 1;
130 default:
131 break;
132 }
133
134 if(rc)
135 break;
136 }
137 }
138
139 /*RTR3Term();*/
140 return rc;
141
142}
143
144#ifdef RT_OS_WINDOWS
145extern "C" int WINAPI WinMain(HINSTANCE hInstance,
146 HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nShowCmd*/)
147{
148 return main(__argc, __argv);
149}
150#endif
151
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette