int gui_main(duc *duc, int argc, char *argv[]) { char *path = "."; if(argc > 0) path = argv[0]; fuzz = opt_fuzz; if(opt_palette) { char c = tolower(opt_palette[0]); if(c == 's') palette = DUC_GRAPH_PALETTE_SIZE; if(c == 'r') palette = DUC_GRAPH_PALETTE_RAINBOW; if(c == 'g') palette = DUC_GRAPH_PALETTE_GREYSCALE; if(c == 'm') palette = DUC_GRAPH_PALETTE_MONOCHROME; } int r = duc_open(duc, opt_database, DUC_OPEN_RO); if(r != DUC_OK) { duc_log(duc, DUC_LOG_FTL, "%s", duc_strerror(duc)); return -1; } dir = duc_dir_open(duc, path); if(dir == NULL) { duc_log(duc, DUC_LOG_FTL, "%s", duc_strerror(duc)); return -1; } dpy = XOpenDisplay(NULL); if(dpy == NULL) { duc_log(duc, DUC_LOG_FTL, "ERROR: Could not open display"); exit(1); } int scr = DefaultScreen(dpy); rootwin = RootWindow(dpy, scr); Window win = XCreateSimpleWindow( dpy, rootwin, 1, 1, win_w, win_h, 0, BlackPixel(dpy, scr), WhitePixel(dpy, scr)); XSelectInput(dpy, win, ExposureMask | ButtonPressMask | StructureNotifyMask | KeyPressMask | PointerMotionMask); XMapWindow(dpy, win); cs = cairo_xlib_surface_create(dpy, win, DefaultVisual(dpy, 0), win_w, win_h); cr = cairo_create(cs); graph = duc_graph_new_cairo(duc, cr); do_gui(duc, graph, dir); duc_dir_close(dir); return 0; }
int guigl_main(duc *duc, int argc, char *argv[]) { char *path = "."; if(argc > 0) path = argv[0]; fuzz = opt_fuzz; if(opt_palette) { char c = tolower(opt_palette[0]); if(c == 's') palette = DUC_GRAPH_PALETTE_SIZE; if(c == 'r') palette = DUC_GRAPH_PALETTE_RAINBOW; if(c == 'g') palette = DUC_GRAPH_PALETTE_GREYSCALE; if(c == 'm') palette = DUC_GRAPH_PALETTE_MONOCHROME; if(c == 'c') palette = DUC_GRAPH_PALETTE_CLASSIC; } int r = duc_open(duc, opt_database, DUC_OPEN_RO); if(r != DUC_OK) { duc_log(duc, DUC_LOG_FTL, "%s", duc_strerror(duc)); return -1; } dir = duc_dir_open(duc, path); if(dir == NULL) { duc_log(duc, DUC_LOG_FTL, "%s", duc_strerror(duc)); return -1; } if(!glfwInit()) { duc_log(duc, DUC_LOG_FTL, "Error initializen glfw"); return -1; } glfwWindowHint(GLFW_SAMPLES, 4); GLFWwindow* window = window = glfwCreateWindow(640, 480, "Duc", NULL, NULL);; if(window == NULL) { duc_log(duc, DUC_LOG_FTL, "Error creating glfw window"); glfwTerminate(); return -1; } glfwMakeContextCurrent(window); gladLoadGLES2Loader((GLADloadproc) glfwGetProcAddress); glfwGetFramebufferSize(window, &win_w, &win_h); double font_scale = 1.0; sc2fb(window, &font_scale, NULL); graph = duc_graph_new_opengl(duc, font_scale); glfwSetKeyCallback(window, cb_keyboard); glfwSetFramebufferSizeCallback(window, cb_winsize); glfwSetMouseButtonCallback(window, cb_mouse_button); glfwSetCursorPosCallback(window, cb_mouse_motion); glfwSetScrollCallback(window, cb_scroll); while (!glfwWindowShouldClose(window)) { draw(window); glfwWaitEvents(); } glfwTerminate(); return 0; }