//Render the phantom based on the vertex representation defined at the top void RenderUtils::RenderPhantom(glm::uvec2 eyeSize){ InitVAO(); glEnable(GL_PROGRAM_POINT_SIZE); glPointSize(20); // This will identify our vertex buffer GLuint vertexbuffer; // Generate 1 buffer, put the resulting identifier in vertexbuffer glGenBuffers(1, &vertexbuffer); // The following commands will talk about our 'vertexbuffer' buffer glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); // Give our vertices to OpenGL. glBufferData(GL_ARRAY_BUFFER, sizeof(g_phantom_buffer_data), g_phantom_buffer_data, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); //std::cout << "checked" << std::endl; glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 ); //glRotatef(45,0.0f,0.0f,1.0f); glDrawArrays(GL_POINTS, 0, 1); glDisableVertexAttribArray(0); }
// Render the breadcrumb based on the vector generated and appended // sequentially void RenderUtils::RenderBreadCrumb(glm::uvec2 eyeSize){ InitVAO(); glEnable(GL_PROGRAM_POINT_SIZE); glPointSize(3); int start = 0; GLfloat g_breadcrumb_buffer_data[g_breadcrumb_buffer_dataVec.size()]; std::copy(g_breadcrumb_buffer_dataVec.begin(), g_breadcrumb_buffer_dataVec.end(), g_breadcrumb_buffer_data); // This will identify our vertex buffer GLuint vertexbuffer; // Generate 1 buffer, put the resulting identifier in vertexbuffer glGenBuffers(1, &vertexbuffer); // The following commands will talk about our 'vertexbuffer' buffer glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); // Give our vertices to OpenGL. glBufferData(GL_ARRAY_BUFFER, sizeof(g_breadcrumb_buffer_data), g_breadcrumb_buffer_data, GL_DYNAMIC_DRAW); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 ); int n = g_breadcrumb_buffer_dataVec.size(); if (n > 20) start = n - 20; glDrawArrays(GL_POINTS, 0, n); glDisableVertexAttribArray(0); }
// Render Gantry based on the vertex representation defined at the top void RenderUtils::RenderGantry(glm::uvec2 eyeSize, float angle, float x, float y){ InitVAO(); // This will identify our vertex buffer GLuint vertexbuffer; // Generate 1 buffer, put the resulting identifier in vertexbuffer glGenBuffers(1, &vertexbuffer); // The following commands will talk about our 'vertexbuffer' buffer glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); // Give our vertices to OpenGL. RotateObject(angle* PI / 180, x, y); glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertex_rotated_buffer_data), g_vertex_rotated_buffer_data, GL_STATIC_DRAW); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer); //std::cout << "checked" << std::endl; glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0 ); //glRotatef(45,0.0f,0.0f,1.0f); glDrawArrays(GL_TRIANGLE_FAN, 0, 10); glDisableVertexAttribArray(0); }
//==================================== // Setup/Init Stuff //==================================== bool Init(int argc, char **argv){ // Set window title to "Student Name: 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); deviceName = deviceProp.name; deviceName = m_yourName + ": " + deviceProp.name; m_major = deviceProp.major; m_minor = deviceProp.minor; // Window setup stuff #if _WIN32 glutInit(&argc, argv); m_width = 800; m_height = 800; glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(m_width, m_height); m_window = glutCreateWindow(deviceName.c_str()); #else 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); #endif 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; }