void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
/** * Initialization of CUDA and GLFW. */ bool init(int argc, char **argv) { // Set window title to "Student Name: [SM 2.0] GPU Name" std::string deviceName; cudaDeviceProp deviceProp; int gpuDevice = 0; int device_count = 0; cudaGetDeviceCount(&device_count); if (gpuDevice > device_count) { std::cout << "Error: GPU device number is greater than the number of devices!" << "Perhaps a CUDA-capable GPU is not installed?" << std::endl; return false; } cudaGetDeviceProperties(&deviceProp, gpuDevice); m_major = deviceProp.major; m_minor = deviceProp.minor; std::ostringstream ss; ss << m_yourName << ": [SM " << m_major << "." << m_minor << "] " << deviceProp.name; deviceName = ss.str(); // Window setup stuff glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } m_width = 800; m_height = 800; m_window = glfwCreateWindow(m_width, m_height, deviceName.c_str(), NULL, NULL); if (!m_window) { glfwTerminate(); return false; } glfwMakeContextCurrent(m_window); glfwSetKeyCallback(m_window, keyCallback); glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { return false; } // init all of the things initVAO(); initTextures(); initCUDA(); initPBO(&m_pbo); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
void initCuda(){ // Use device with highest Gflops/s // Had to update this to remove cutil version cudaGLSetGLDevice( gpuGetMaxGflopsDeviceId() ); initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); prev_time = 0.0f; //struct tm* t0; runCuda(); }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); initPBO(&pbo); dptr=NULL; cudaGLMapBufferObject((void**)&dptr, pbo); clearPBOpos(dptr,width,height); cudaGLUnmapBufferObject(pbo); // Clean up on program exit atexit(cleanupCuda); SetScissorWindow(glm::vec4(300,300,500,500)); texture.mapptr = stbi_load("cow.jpeg",&texture.width, &texture.height,&texture.depth,0); runCuda(); }
void initCuda(){ // Use device with highest Gflops/s #if CUDA_VERSION >= 5000 cudaGLSetGLDevice( gpuGetMaxGflopsDeviceId() ); #else cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); #endif initPBO(&pbo); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( cutGetMaxGflopsDeviceId() ); initPBO(&pbo); paraMap = new float[(int)renderCam->resolution.x *(int)renderCam->resolution.y]; effectiveRayMap =new int[(int)renderCam->resolution.x *(int)renderCam->resolution.y]; initialRayMap = new ray[(int)renderCam->resolution.x * (int)renderCam->resolution.y]; generateRayMap(renderCam, targetFrame); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
bool init(obj *mesh) { glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } width = 350; height = 350; window = glfwCreateWindow(width, height, "CIS 565 Pathtracer", NULL, NULL); if (!window) { glfwTerminate(); return false; } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, keyCallback); // Set up GL context glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) { return false; } // Initialize other stuff initVAO(); initTextures(); initCuda(); initPBO(); float cbo[] = { 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 0.0 }; rasterizeSetBuffers(mesh->getBufIdxsize(), mesh->getBufIdx(), mesh->getBufPossize() / 3, mesh->getBufPos(), mesh->getBufNor(), mesh->getBufCol()); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
void initCuda(){ // Use device with highest Gflops/s cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); initPBO(&pbo); modelView = glm::lookAt(cameraPosition, lookat, up); projection = glm::perspective(fovy, float(width) / float(height), zNear, zFar); viewPort[0] = glm::vec4(-float(width)/2,0,0,0.0f); viewPort[1] = glm::vec4(0,-(float)height/2,0,0.0f); viewPort[2] = glm::vec4(0,0,1.f/2.0f,0.0f); viewPort[3] = glm::vec4((float)width/2,(float)height/2,1.0f/2.0f,1.0f); // Clean up on program exit atexit(cleanupCuda); runCuda(); }
bool init(int argc, char* argv[]) { glfwSetErrorCallback(errorCallback); if (!glfwInit()) { return false; } width = 800; height = 800; window = glfwCreateWindow(width, height, "CIS 565 Rasterizer", NULL, NULL); if (!window){ glfwTerminate(); return false; } glfwMakeContextCurrent(window); glfwSetKeyCallback(window, keyCallback); glfwSetMouseButtonCallback(window,MouseClickCallback); glfwSetCursorEnterCallback(window,CursorEnterCallback); glfwSetCursorPosCallback(window,CursorCallback); // Set up GL context glewExperimental = GL_TRUE; if(glewInit()!=GLEW_OK){ return false; } // Initialize other stuff initVAO(); initTextures(); initCuda(); initPBO(); GLuint passthroughProgram; passthroughProgram = initShader(); glUseProgram(passthroughProgram); glActiveTexture(GL_TEXTURE0); return true; }
int main(int argc, char** argv) { // Launch CUDA/GL init(argc, argv); cudaGLSetGLDevice( compat_getMaxGflopsDeviceId() ); initPBO(&pbo); cudaGLRegisterBufferObject( planetVBO ); #if VISUALIZE == 1 initCuda(N_FOR_VIS); #else initCuda(2*128); #endif projection = glm::perspective(fovy, float(width)/float(height), zNear, zFar); view = glm::lookAt(cameraPosition, glm::vec3(0), glm::vec3(0,0,1)); projection = projection * view; GLuint passthroughProgram; initShaders(program); glUseProgram(program[HEIGHT_FIELD]); glActiveTexture(GL_TEXTURE0); glEnable(GL_DEPTH_TEST); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutMainLoop(); return 0; }
void Renderer::init() { fullScreenQuad.begin(); initPBO(); initCUDAMemory(); }