Changeset 94137 in vbox for trunk/src/VBox/Main/src-helper-apps
- Timestamp:
- Mar 8, 2022 10:10:28 PM (3 years ago)
- Location:
- trunk/src/VBox/Main/src-helper-apps/OpenGLTest
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-helper-apps/OpenGLTest/Makefile.kmk
r93115 r94137 44 44 45 45 ifdef VBOX_WITH_VIDEOHWACCEL 46 USES += qt5 46 ifndef VBOX_WITH_QT6 47 USES += qt5 48 else 49 USES += qt6 50 endif 47 51 endif 48 52 PROGRAMS += VBoxTestOGL … … 60 64 VBoxTestOGL_SOURCES.win = VBoxTestOGL.rc 61 65 VBoxTestOGL_LIBS = $(LIB_RUNTIME) 66 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # the X11 gang 67 VBoxTestOGL_LIBS += \ 68 X11 \ 69 Xext 70 VBoxTestOGL_LIBPATH = \ 71 $(VBOX_LIBPATH_X11) 72 endif 73 62 74 ifdef VBOX_WITH_VIDEOHWACCEL 63 75 VBoxTestOGL_DEFS += VBOX_WITH_VIDEOHWACCEL 64 76 VBoxTestOGL_LIBS <= $(PATH_STAGE_LIB)/VBoxOGL2D$(VBOX_SUFF_LIB) 65 VBoxTestOGL_QT_MODULES += Core Gui OpenGL Widgets 77 VBoxTestOGL_QT_MODULES = Core Gui OpenGL Widgets 78 ifdef VBOX_WITH_QT6 79 VBoxTestOGL_QT_MODULES += OpenGLWidgets 80 endif 66 81 VBoxTestOGL_LIBS.linux += xcb 67 82 VBoxTestOGL_LIBS.solaris += xcb … … 72 87 VBoxTestOGL_LIBS += GL pthread dl 73 88 endif 74 ## @todo not sure why this is a separate library, but whatever. 89 90 ## @todo bird: not sure WTF this is a separate library. Makes no sense... 75 91 LIBRARIES += VBoxOGL2D 76 92 VBoxOGL2D_TEMPLATE = $(if $(VBOX_WITH_VIDEOHWACCEL),$(if $(VBOX_WITH_HARDENING),VBOXQTGUI,VBOXQTGUIEXE),VBOXMAINEXE) 77 93 VBoxOGL2D_DEFS = QT_NO_DEBUG QT_THREAD_SUPPORT QT_SHARED HAVE_CONFIG_H VBOX_WITH_VIDEOHWACCEL VBOX_GUI_USE_QGL 78 VBoxOGL2D_QT_MODULES += OpenGL 94 VBoxOGL2D_QT_MODULES = Gui OpenGL 95 ifdef VBOX_WITH_QT6 96 VBoxOGL2D_QT_MODULES += Widgets OpenGLWidgets 97 endif 79 98 VBoxOGL2D_SOURCES = VBoxGLSupportInfo.cpp 80 endif81 if1of ($(KBUILD_TARGET), freebsd linux netbsd openbsd solaris) # the X11 gang82 VBoxTestOGL_LIBS += \83 X11 \84 Xext85 VBoxTestOGL_LIBPATH = \86 $(VBOX_LIBPATH_X11)87 99 endif 88 100 -
trunk/src/VBox/Main/src-helper-apps/OpenGLTest/OpenGLTestApp.cpp
r93115 r94137 22 22 #include <iprt/initterm.h> 23 23 #include <iprt/ldr.h> 24 #include <iprt/message.h> 24 25 #include <iprt/stream.h> 25 26 #ifdef RT_OS_WINDOWS … … 50 51 #endif /* VBOXGLTEST_WITH_LOGGING */ 51 52 52 #ifdef VBOX_WITH_VIDEOHWACCEL53 # include <QGLWidget>54 # include <QApplication>55 # include <VBox/VBoxGL2D.h>56 #endif57 58 53 #ifndef RT_OS_WINDOWS 59 54 # include <GL/gl.h> /* For GLubyte and friends. */ 55 #endif 56 57 #ifdef VBOX_WITH_VIDEOHWACCEL 58 # include <QApplication> 59 # if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 60 # include <QSurfaceFormat> 61 # endif 62 # include <VBox/VBoxGL2D.h> 60 63 #endif 61 64 … … 246 249 { 247 250 LogRel(("Testing 2D Support:\n")); 248 static int dummyArgc = 1;249 static char * dummyArgv = (char*)"GlTest";250 QApplication app (dummyArgc, &dummyArgv);251 char *apszDummyArgs[] = { (char *)"GLTest", NULL }; 252 int cDummyArgs = RT_ELEMENTS(apszDummyArgs) - 1; 253 QApplication app(cDummyArgs, apszDummyArgs); 251 254 252 255 VBoxGLTmpContext ctx; 253 const QGLContext *pContext = ctx.makeCurrent();254 if (pContext)256 const MY_QOpenGLContext *pContext = ctx.makeCurrent(); 257 if (pContext) 255 258 { 256 259 VBoxVHWAInfo supportInfo; 257 260 supportInfo.init(pContext); 258 if (supportInfo.isVHWASupported())261 if (supportInfo.isVHWASupported()) 259 262 { 260 263 LogRel(("Testing 2D Succeeded!\n")); … … 374 377 int main(int argc, char **argv) 375 378 { 379 RTR3InitExe(argc, &argv, 0); 380 376 381 int rc = 0; 377 378 RTR3InitExe(argc, &argv, 0); 379 380 if(argc < 2) 382 if (argc < 2) 381 383 { 382 384 /* backwards compatibility: check 3D */ … … 391 393 #ifdef VBOXGLTEST_WITH_LOGGING 392 394 { "--log", 'l', RTGETOPT_REQ_STRING }, 395 { "--log-to-stdout", 'L', RTGETOPT_REQ_NOTHING }, 393 396 #endif 394 397 }; 395 398 396 399 RTGETOPTSTATE State; 397 rc = RTGetOptInit(&State, argc -1, argv+1, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 0, 0);400 rc = RTGetOptInit(&State, argc, argv, &s_aOptionDefs[0], RT_ELEMENTS(s_aOptionDefs), 1, 0); 398 401 AssertRCReturn(rc, 49); 399 402 … … 418 421 case 't': 419 422 if (!strcmp(Val.psz, "3D") || !strcmp(Val.psz, "3d")) 420 {421 423 bTest3D = true; 422 rc = 0;423 break;424 }425 424 #ifdef VBOX_WITH_VIDEOHWACCEL 426 if (!strcmp(Val.psz, "2D") || !strcmp(Val.psz, "2d")) 427 { 425 else if (!strcmp(Val.psz, "2D") || !strcmp(Val.psz, "2d")) 428 426 bTest2D = true; 429 rc = 0; 430 break; 431 } 432 #endif 433 rc = 1; 427 #endif 428 else 429 return RTMsgErrorExit(RTEXITCODE_FAILURE, "Unknown test: %s", Val.psz); 434 430 break; 431 435 432 #ifdef VBOXGLTEST_WITH_LOGGING 436 433 case 'l': 437 434 bLog = true; 438 435 pLog = Val.psz; 439 rc = 0; 436 break; 437 case 'L': 438 bLog = true; 439 pLog = NULL; 440 440 break; 441 441 #endif … … 452 452 #ifdef VBOXGLTEST_WITH_LOGGING 453 453 " --log <log_file_name> log the GL test result to the given file\n" 454 " --log-to-stdout log the GL test result to stdout\n" 454 455 "\n" 455 456 "Logging can alternatively be enabled by specifying the VBOXGLTEST_LOG=<log_file_name> env variable\n" … … 458 459 "\n", 459 460 RTBldCfgVersionMajor(), RTBldCfgVersionMinor(), RTBldCfgVersionBuild()); 460 break;461 return RTEXITCODE_SUCCESS; 461 462 462 463 case 'V': 463 464 RTPrintf("$Revision$\n"); 464 return 0;465 return RTEXITCODE_SUCCESS; 465 466 466 467 case VERR_GETOPT_UNKNOWN_OPTION: 467 468 case VINF_GETOPT_NOT_OPTION: 468 rc = 1;469 470 469 default: 471 /* complain? RTGetOptPrintError(rc, &Val); */ 472 break; 470 return RTGetOptPrintError(rc, &Val); 473 471 } 474 475 if (rc) 476 break; 477 } 478 479 if(!rc) 480 { 481 #ifdef VBOXGLTEST_WITH_LOGGING 482 if(!bLog) 483 { 484 /* check the VBOXGLTEST_LOG env var */ 485 pLog = RTEnvGet("VBOXGLTEST_LOG"); 486 if(pLog) 487 bLog = true; 488 bLogSuffix = true; 489 } 490 if(bLog) 491 rc = vboxInitLogging(pLog, bLogSuffix); 492 else 493 #endif 494 rc = vboxInitQuietMode(); 495 496 if(!rc && bTest3D) 497 rc = vboxCheck3DAccelerationSupported(); 472 } 473 474 /* 475 * Init logging and output. 476 */ 477 #ifdef VBOXGLTEST_WITH_LOGGING 478 if (!bLog) 479 { 480 /* check the VBOXGLTEST_LOG env var */ 481 pLog = RTEnvGet("VBOXGLTEST_LOG"); 482 if(pLog) 483 bLog = true; 484 bLogSuffix = true; 485 } 486 if (bLog) 487 rc = vboxInitLogging(pLog, bLogSuffix); 488 else 489 #endif 490 rc = vboxInitQuietMode(); 491 492 /* 493 * Do the job. 494 */ 495 if (!rc && bTest3D) 496 rc = vboxCheck3DAccelerationSupported(); 498 497 499 498 #ifdef VBOX_WITH_VIDEOHWACCEL 500 if(!rc && bTest2D) 501 rc = vboxCheck2DVideoAccelerationSupported(); 502 #endif 503 504 } 499 if (!rc && bTest2D) 500 rc = vboxCheck2DVideoAccelerationSupported(); 501 #endif 505 502 } 506 503 -
trunk/src/VBox/Main/src-helper-apps/OpenGLTest/VBoxGLSupportInfo.cpp
r93115 r94137 20 20 # include <iprt/stdint.h> /* QGLWidget drags in stdint.h; -Wall forces us to use wrapper. */ 21 21 #endif 22 #include <QGLWidget> 22 23 #include <QGuiApplication> /* For QT_VERSION */ 24 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 25 # include <QMainWindow> 26 # include <QOpenGLWidget> 27 # include <QOpenGLContext> 28 #else 29 # include <QGLWidget> 30 #endif 23 31 24 32 #include <iprt/assert.h> … … 36 44 #include <iprt/err.h> 37 45 38 #include <QGLContext>39 40 46 41 47 /*****************/ … … 98 104 PFNVBOXVHWA_GET_FRAMEBUFFER_ATTACHMENT_PARAMETRIV vboxglGetFramebufferAttachmentParameteriv = NULL; 99 105 100 #define VBOXVHWA_GETPROCADDRESS(_c, _t, _n) ((_t)(uintptr_t)(_c).getProcAddress( QString(_n)))106 #define VBOXVHWA_GETPROCADDRESS(_c, _t, _n) ((_t)(uintptr_t)(_c).getProcAddress(_n)) 101 107 102 108 #define VBOXVHWA_PFNINIT_SAME(_c, _t, _v, _rc) \ … … 251 257 } 252 258 253 void VBoxGLInfo::init(const QGLContext *pContext)254 { 255 if (mInitialized)259 void VBoxGLInfo::init(const MY_QOpenGLContext *pContext) 260 { 261 if (mInitialized) 256 262 return; 257 263 258 264 mInitialized = true; 259 265 266 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) 260 267 if (!QGLFormat::hasOpenGL()) 261 268 { … … 263 270 return; 264 271 } 272 #endif 265 273 266 274 // pContext->makeCurrent(); … … 271 279 ); 272 280 273 if (str)281 if (str) 274 282 { 275 283 VBOXQGLLOGREL (("gl version string: 0%s\n", str)); … … 336 344 } 337 345 338 void VBoxGLInfo::initExtSupport(const QGLContext &context)346 void VBoxGLInfo::initExtSupport(const MY_QOpenGLContext &context) 339 347 { 340 348 int rc = 0; … … 532 540 } 533 541 534 void VBoxVHWAInfo::init(const QGLContext *pContext)542 void VBoxVHWAInfo::init(const MY_QOpenGLContext *pContext) 535 543 { 536 544 if(mInitialized) … … 662 670 /** @todo test & enable external app approach*/ 663 671 VBoxGLTmpContext ctx; 664 const QGLContext *pContext = ctx.makeCurrent();672 const MY_QOpenGLContext *pContext = ctx.makeCurrent(); 665 673 Assert(pContext); 666 if (pContext)674 if (pContext) 667 675 { 668 676 VBoxVHWAInfo info; … … 676 684 VBoxGLTmpContext::VBoxGLTmpContext() 677 685 { 678 if(QGLFormat::hasOpenGL()) 679 { 680 mWidget = new QGLWidget(); 681 } 686 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 687 mWidget = new MY_QOpenGLWidget(/*new QMainWindow()*/); 688 #else 689 if (QGLFormat::hasOpenGL()) 690 mWidget = new MY_QOpenGLWidget(); 682 691 else 683 {684 692 mWidget = NULL; 685 } 693 #endif 686 694 } 687 695 688 696 VBoxGLTmpContext::~VBoxGLTmpContext() 689 697 { 690 if(mWidget) 698 if (mWidget) 699 { 691 700 delete mWidget; 692 } 693 694 const class QGLContext * VBoxGLTmpContext::makeCurrent() 695 { 696 if(mWidget) 697 { 701 mWidget = NULL; 702 } 703 } 704 705 const MY_QOpenGLContext *VBoxGLTmpContext::makeCurrent() 706 { 707 if (mWidget) 708 { 709 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) 710 mWidget->grabFramebuffer(); /* This is a hack to trigger GL initialization or context() will return NULL. */ 711 #endif 698 712 mWidget->makeCurrent(); 699 713 return mWidget->context();
Note:
See TracChangeset
for help on using the changeset viewer.