tests/cuda2.2/tests/SimpleGL/simpleGL.cpp
CUTBoolean runTest(int argc, char** argv)
{
    if (!cutCheckCmdLineFlag(argc, (const char **)argv, "noqatest") ||
		cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) 
	{
        g_bQAReadback = true;
        fpsLimit = frameCheckNumber;
    }

    // First initialize OpenGL context, so we can properly set the GL for CUDA.
    // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop.
    if (CUTFalse == initGL(argc, argv)) {
        return CUTFalse;
    }

	// use command-line specified CUDA device, otherwise use device with highest Gflops/s
    if( cutCheckCmdLineFlag(argc, (const char**)argv, "device") )
        cutilGLDeviceInit(argc, argv);
    else {
        cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() );
    }

    // Create the CUTIL timer
    cutilCheckError( cutCreateTimer( &timer));

    // register callbacks
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);

    if (g_bQAReadback) {
        g_CheckRender = new CheckBackBuffer(window_width, window_height, 4);
        g_CheckRender->setPixelFormat(GL_RGBA);
        g_CheckRender->setExecPath(argv[0]);
        g_CheckRender->EnableQAReadback(true);
    }

    // create VBO
    createVBO(&vbo);

    // run the cuda part
    runCuda(vbo);

    // check result of Cuda step
    checkResultCuda(argc, argv, vbo);

    atexit(cleanup);

    // start rendering mainloop
    glutMainLoop();

    cudaThreadExit();

	return CUTTrue;
}
////////////////////////////////////////////////////////////////////////////////
//! Run a simple test for CUDA
////////////////////////////////////////////////////////////////////////////////
Run a simple test for CUDA
Run a simple test for CUDA
CUTBoolean runTest(int argc, char** argv)
{
    if (!cutCheckCmdLineFlag(argc, (const char **)argv, "noqatest") ||
		cutCheckCmdLineFlag(argc, (const char **)argv, "noprompt")) 
	{
        g_bQAReadback = true;
        fpsLimit = frameCheckNumber;
    }
    if (CUTFalse == initGL(argc, argv)) {
        return CUTFalse;
    }
    if( cutCheckCmdLineFlag(argc, (const char**)argv, "device") )
        cutilGLDeviceInit(argc, argv);
    else {
        cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() );
    }
    cutilCheckError( cutCreateTimer( &timer));
    glutDisplayFunc(display);
    glutKeyboardFunc(keyboard);
    glutMouseFunc(mouse);
    glutMotionFunc(motion);
    if (g_bQAReadback) {
        g_CheckRender = new CheckBackBuffer(window_width, window_height, 4);
        g_CheckRender->setPixelFormat(GL_RGBA);
        g_CheckRender->setExecPath(argv[0]);
        g_CheckRender->EnableQAReadback(true);
    }
    createVBO(&vbo);
    runCuda(vbo);
    checkResultCuda(argc, argv, vbo);
    atexit(cleanup);
    glutMainLoop();
    cudaThreadExit();
	return CUTTrue;
}
CUTBoolean runTest ( int argc , char * * argv ) { if ( ! cutCheckCmdLineFlag ( argc , ( const char * * ) argv , " " ) || cutCheckCmdLineFlag ( argc , ( const char * * ) argv , " " ) ) { g_bQAReadback = true ; fpsLimit = frameCheckNumber ; } if ( CUTFalse == initGL ( argc , argv ) ) { return CUTFalse ; } if ( cutCheckCmdLineFlag ( argc , ( const char * * ) argv , " " ) ) cutilGLDeviceInit ( argc , argv ) ; else { cudaGLSetGLDevice ( cutGetMaxGflopsDeviceId ( ) ) ; } cutilCheckError ( cutCreateTimer ( & timer ) ) ; glutDisplayFunc ( display ) ; glutKeyboardFunc ( keyboard ) ; glutMouseFunc ( mouse ) ; glutMotionFunc ( motion ) ; if ( g_bQAReadback ) { g_CheckRender = new CheckBackBuffer ( window_width , window_height , 4 ) ; g_CheckRender -> setPixelFormat ( GL_RGBA ) ; g_CheckRender -> setExecPath ( argv [ 0 ] ) ; g_CheckRender -> EnableQAReadback ( true ) ; } createVBO ( & vbo ) ; runCuda ( vbo ) ; checkResultCuda ( argc , argv , vbo ) ; atexit ( cleanup ) ; glutMainLoop ( ) ; cudaThreadExit ( ) ; return CUTTrue ; }
Run a simple test for CUDA
Run a simple test for CUDA
// First initialize OpenGL context, so we can properly set the GL for CUDA. // This is necessary in order to achieve optimal performance with OpenGL/CUDA interop. // use command-line specified CUDA device, otherwise use device with highest Gflops/s // Create the CUTIL timer // register callbacks // create VBO // run the cuda part // check result of Cuda step // start rendering mainloop