MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / runStdProgram

Function runStdProgram

cpp/0_Introduction/simpleCUDA2GL/main.cpp:649–698  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Run standard demo loop with or without GL verification ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

647//! Run standard demo loop with or without GL verification
648////////////////////////////////////////////////////////////////////////////////
649void runStdProgram(int argc, char **argv)
650{
651 // First initialize OpenGL context, so we can properly set the GL for CUDA.
652 // This is necessary in order to achieve optimal performance with OpenGL/CUDA
653 // interop.
654 if (false == initGL(&argc, argv)) {
655 return;
656 }
657
658 // Now initialize CUDA context (GL context has been created already)
659 findCudaDevice(argc, (const char **)argv);
660
661 sdkCreateTimer(&timer);
662 sdkResetTimer(&timer);
663
664 // register callbacks
665 glutDisplayFunc(display);
666 glutKeyboardFunc(keyboard);
667 glutReshapeFunc(reshape);
668 glutTimerFunc(REFRESH_DELAY, timerEvent, 0);
669
670 // create menu
671 glutCreateMenu(mainMenu);
672 glutAddMenuEntry("Quit (esc)", '\033');
673 glutAttachMenu(GLUT_RIGHT_BUTTON);
674
675 initGLBuffers();
676#ifndef USE_TEXSUBIMAGE2D
677 initCUDABuffers();
678#endif
679
680 // Creating the Auto-Validation Code
681 if (ref_file) {
682 g_CheckRender = new CheckBackBuffer(window_width, window_height, 4);
683 g_CheckRender->setPixelFormat(GL_RGBA);
684 g_CheckRender->setExecPath(argv[0]);
685 g_CheckRender->EnableQAReadback(true);
686 }
687
688 printf("\n"
689 "\tControls\n"
690 "\t(right click mouse button for Menu)\n"
691 "\t[esc] - Quit\n\n");
692
693 // start rendering mainloop
694 glutMainLoop();
695
696 // Normally unused return path
697 Cleanup(EXIT_SUCCESS);
698}
699
700////////////////////////////////////////////////////////////////////////////////
701//! Initialize GL

Callers 1

mainFunction · 0.70

Calls 10

findCudaDeviceFunction · 0.85
sdkCreateTimerFunction · 0.85
sdkResetTimerFunction · 0.85
initGLFunction · 0.70
initGLBuffersFunction · 0.70
initCUDABuffersFunction · 0.70
CleanupFunction · 0.70
setPixelFormatMethod · 0.45
setExecPathMethod · 0.45
EnableQAReadbackMethod · 0.45

Tested by

no test coverage detected