// This auxiliary function has been adapted from work done by Ricardo Marques // in the context of his thesis. cl_program programFromSource(const std::string &fileName, const cl_context context){ std::ifstream kernelFile(fileName.data(), std::ios::in); if (!kernelFile.is_open()){ kernelFile.close(); throw; } int errcode; cl_program program; std::ostringstream oss; oss << kernelFile.rdbuf(); std::string srcStdStr = oss.str(); const char *srcStr = srcStdStr.c_str(); program = clCreateProgramWithSource(context, 1, (const char**)&srcStr, NULL, &errcode); if(errcode != CL_SUCCESS){ std::cerr << errorString(errcode) << std::endl; return NULL; } return program; }
void readFile(char * filename) { string line; cout << "opening " << filename << endl; ifstream file(filename); if (file == NULL) { cout << "Could not open file" << endl; exit (EXIT_FAILURE); } double x, y, x2, y2; file >> x; file >> y; file >> x2; file >> y2; screenWidth = x2; screenHeight = y; glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(500, 500); glutInitWindowPosition(100, 150); glutCreateWindow("Drawing"); stringstream ss; file >> x; for (int i = 0; i < x; i++) { vector<point> points; file >> y; for (int j = 0; j < y; j++) { point p; file >> x2; file >> y2; p.x = x2; p.y = y2; points.push_back(p); } cors.push_back(points); } file.close(); }