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

Function initGL

cpp/4_CUDA_Libraries/oceanFFT/oceanFFT.cpp:699–742  ·  view source on GitHub ↗

/////////////////////////////////////////////////////////////////////////// Initialize GL ///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

697//! Initialize GL
698////////////////////////////////////////////////////////////////////////////////
699bool initGL(int *argc, char **argv)
700{
701 // Create GL context
702 glutInit(argc, argv);
703 glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH);
704 glutInitWindowSize(windowW, windowH);
705 glutCreateWindow("CUDA FFT Ocean Simulation");
706
707 vertShaderPath = sdkFindFilePath("ocean.vert", argv[0]);
708 fragShaderPath = sdkFindFilePath("ocean.frag", argv[0]);
709
710 if (vertShaderPath == NULL || fragShaderPath == NULL) {
711 fprintf(stderr, "Error unable to find GLSL vertex and fragment shaders!\n");
712 exit(EXIT_FAILURE);
713 }
714
715 // initialize necessary OpenGL extensions
716
717 if (!isGLVersionSupported(2, 0)) {
718 fprintf(stderr, "ERROR: Support for necessary OpenGL extensions missing.");
719 fflush(stderr);
720 return false;
721 }
722
723 if (!areGLExtensionsSupported("GL_ARB_vertex_buffer_object GL_ARB_pixel_buffer_object")) {
724 fprintf(stderr, "Error: failed to get minimal extensions for demo\n");
725 fprintf(stderr, "This sample requires:\n");
726 fprintf(stderr, " OpenGL version 1.5\n");
727 fprintf(stderr, " GL_ARB_vertex_buffer_object\n");
728 fprintf(stderr, " GL_ARB_pixel_buffer_object\n");
729 cleanup();
730 exit(EXIT_FAILURE);
731 }
732
733 // default initialization
734 glClearColor(0.0, 0.0, 0.0, 1.0);
735 glEnable(GL_DEPTH_TEST);
736
737 // load shader
738 shaderProg = loadGLSLProgram(vertShaderPath, fragShaderPath);
739
740 SDK_CHECK_ERROR_GL();
741 return true;
742}
743
744////////////////////////////////////////////////////////////////////////////////
745//! Create VBO

Callers 1

runGraphicsTestFunction · 0.70

Calls 5

sdkFindFilePathFunction · 0.85
isGLVersionSupportedFunction · 0.85
areGLExtensionsSupportedFunction · 0.85
loadGLSLProgramFunction · 0.85
cleanupFunction · 0.70

Tested by

no test coverage detected