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

Function display

cpp/0_Introduction/simpleCUDA2GL/main.cpp:331–379  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Display callback ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

329//! Display callback
330////////////////////////////////////////////////////////////////////////////////
331void display()
332{
333 sdkStartTimer(&timer);
334
335 if (enable_cuda) {
336 generateCUDAImage();
337 displayImage(tex_cudaResult);
338 }
339
340 // NOTE: I needed to add this call so the timing is consistent.
341 // Need to investigate why
342 cudaDeviceSynchronize();
343 sdkStopTimer(&timer);
344
345 // flip backbuffer
346 glutSwapBuffers();
347
348 // If specified, Check rendering against reference,
349 if (ref_file && g_CheckRender && g_CheckRender->IsQAReadback()) {
350 static int pass = 0;
351
352 if (pass > 0) {
353 g_CheckRender->readback(window_width, window_height);
354 char currentOutputPPM[256];
355 sprintf(currentOutputPPM, "kilt.ppm");
356 g_CheckRender->savePPM(currentOutputPPM, true, NULL);
357
358 if (!g_CheckRender->PPMvsPPM(currentOutputPPM, sdkFindFilePath(ref_file, pArgv[0]), MAX_EPSILON, 0.30f)) {
359 g_TotalErrors++;
360 }
361
362 Cleanup((g_TotalErrors == 0) ? EXIT_SUCCESS : EXIT_FAILURE);
363 }
364
365 pass++;
366 }
367
368 // Update fps counter, fps/title display and log
369 if (++fpsCount == fpsLimit) {
370 char cTitle[256];
371 float fps = 1000.0f / sdkGetAverageTimerValue(&timer);
372 sprintf(cTitle, "CUDA GL Post Processing (%d x %d): %.1f fps", window_width, window_height, fps);
373 glutSetWindowTitle(cTitle);
374 // printf("%s\n", cTitle);
375 fpsCount = 0;
376 fpsLimit = (int)((fps > 1.0f) ? fps : 1.0f);
377 sdkResetTimer(&timer);
378 }
379}
380
381void timerEvent(int value)
382{

Callers

nothing calls this directly

Calls 12

sdkStartTimerFunction · 0.85
generateCUDAImageFunction · 0.85
sdkStopTimerFunction · 0.85
sdkFindFilePathFunction · 0.85
sdkGetAverageTimerValueFunction · 0.85
sdkResetTimerFunction · 0.85
displayImageFunction · 0.70
CleanupFunction · 0.70
IsQAReadbackMethod · 0.45
readbackMethod · 0.45
savePPMMethod · 0.45
PPMvsPPMMethod · 0.45

Tested by

no test coverage detected