bool Mapgen_spec_pool::load_from(std::string filename) { std::ifstream fin; fin.open(filename.c_str()); if (!fin.is_open()) { debugmsg("Failed to open '%s'", filename.c_str()); return false; } while (!fin.eof()) { if (!load_element(fin)) { return false; } } return true; }
int video_display_process(uint8_t* frame, int width, int height, int size) { //if we get a NULL frame, stop displaying. if(frame == NULL) { video_display_destroy(); return 0; } //first time called ? Initialize things. if(!initialized) { if(video_display_init_size(width, height) < 0) { fprintf(stderr, "[~][Display] Failed initialization.\n"); return -1; } if(video_display_set_size(width, height) < 0) return -1; initialized = 1; } //check whether the size of the video has changed if (width != current_width || height != current_height) if (video_display_set_size(width, height) < 0) return -1; //check whether there's new stuff in the input com buffer double new_update = jakopter_com_get_timestamp(com_in); if (new_update > prev_update) { update_infos(); if (want_screenshot) { take_screenshot(frame, size); want_screenshot = 0; jakopter_com_write_int(com_in, 24, 0); } prev_update = new_update; } pthread_mutex_lock(&mutex_process); if (current_process != NULL) { current_process(frame, width, height, size); } pthread_mutex_unlock(&mutex_process); unload_element(); if (load_element() < 0) fprintf(stderr, "Couldn't load graphic element\n"); // update the texture with our new frame if (SDL_UpdateTexture(frameTex, NULL, frame, width) < 0) { fprintf(stderr, "[~][Display] Failed to update frame texture : %s\n", SDL_GetError()); return -1; } //clear the renderer, then update it so that we get the new frame displayed. SDL_RenderClear(renderer); SDL_RenderCopy(renderer, frameTex, NULL, NULL); //SDL_RenderFillRect(renderer, &rectangle); //draw all overlay elements, when they exist int i = 0; for (i = 0 ; i < VIDEO_NB_NAV_INFOS ; i++) if (graphs[i].tex != NULL) SDL_RenderCopy(renderer, graphs[i].tex, NULL, &graphs[i].pos); pthread_mutex_lock(&mutex_graphics_list); struct graphics_list *current = icon_registry; while (current != NULL) { if (current->graphic != NULL && current->graphic->tex != NULL){ int ret = SDL_RenderCopy(renderer, current->graphic->tex, NULL, ¤t->graphic->pos); if (ret < 0) fprintf(stderr, "[~][display] RenderCopy() failed: %s\n", SDL_GetError()); } current = current->next; } pthread_mutex_unlock(&mutex_graphics_list); draw_attitude_indic(); draw_compass(); SDL_RenderPresent(renderer); return 0; }