statistics_dialog::statistics_dialog(game_display &disp, const std::string& title, const unsigned int team, const std::string& team_id, const std::string& player) : dialog(disp.video(), title, "", gui::NULL_DIALOG), detail_btn_(new gui::standard_dialog_button(disp.video(), _("Details"), 0 , false)), toggle_btn_(new gui::dialog_button(disp.video(), "", gui::button::TYPE_PRESS, BUTTON_TOGGLE)), scene_btn_(new gui::dialog_button(disp.video(), _("Select Scenario"), gui::button::TYPE_PRESS, BUTTON_SCENE)), player_name_(player), campaign_(statistics::calculate_stats(team_id)), scenarios_(statistics::level_stats(team_id)), scenario_index_(scenarios_.size() - 1), // current scenario team_num_(team), unit_count_(5,0) { if ( scenarios_.size() > 1 ) { add_button(scene_btn_, gui::dialog::BUTTON_EXTRA_LEFT); add_button(toggle_btn_, gui::dialog::BUTTON_EXTRA_LEFT); } add_button(detail_btn_, gui::dialog::BUTTON_EXTRA); add_button(new gui::standard_dialog_button(disp.video(), _("Close"), 1, true), gui::dialog::BUTTON_STANDARD); // Initialize the displayed data. if ( use_campaign_ || scenarios_.size() == 1 ) display_stats(use_campaign_); else { // Starting with the scenario stats, but we need to make sure the // window is wide enough for the campaign stats. display_stats(true); layout(); display_stats(false); } }
void terminate(void) { fprintf(stderr, "unpartition !!\n"); starpu_data_unpartition(C_handle, 0); starpu_data_unregister(C_handle); gettimeofday(&end, NULL); double timing = (double)((end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec)); display_stats(timing); #ifdef CHECK_OUTPUT /* check results */ /* compute C = C - AB */ SGEMM("N", "N", ydim, xdim, zdim, -1.0f, A, ydim, B, zdim, 1.0f, C, ydim); /* make sure C = 0 */ float err; err = SASUM(xdim*ydim, C, 1); if (err < xdim*ydim*0.001) { fprintf(stderr, "Results are OK\n"); } else { fprintf(stderr, "There were errors ... err = %f\n", err); } #endif // CHECK_OUTPUT }
/* Create a file of size file_size */ static uint64_t create_file(const char *file_name, uint64_t file_size) { int fd; int flags; mode_t mode; uint64_t actual_size; /* Less than size if the file system is full */ flags = O_CREAT | O_TRUNC | O_WRONLY; mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; before(); fd = open(file_name, flags, mode); if (fd == -1 && errno == ENOSPC) { errno = 0; after("open"); fprintf(stderr,"\nrndrm99: open failed with ENOSPC\n");fflush(stderr); display_stats(); return 0; /* File system full */ } CHECK(fd != -1); after("open"); actual_size = fill_file(fd, file_size); before(); CHECK(close(fd) != -1); after("close"); if (file_size != 0 && actual_size == 0) { printf("\nrndrm99: unlinking zero size file\n");fflush(stdout); before(); CHECK(unlink(file_name) != -1); after("unlink (create_file)"); } return actual_size; }
// //========================================================================= // // This function is called a few times every second by main in order to // perform tasks we need to do continuously, like accepting new clients // from the net, refreshing the screen in interactive mode, and so forth // void backgroundTasks(void) { static time_t next_stats; if (Modes.net) { modesReadFromClients(); } // If Modes.aircrafts is not NULL, remove any stale aircraft if (Modes.aircrafts) { interactiveRemoveStaleAircrafts(); } // Refresh screen when in interactive mode if (Modes.interactive) { interactiveShowData(); } if (Modes.stats > 0) { time_t now = time(NULL); if (now > next_stats) { if (next_stats != 0) display_stats(); next_stats = now + Modes.stats; } } }
int main(int argc, char *argv[]) { int ret = 0; int i = 0; ret = argp_parse (&argp, argc, argv, 0, 0, NULL); if (ret != 0) { fprintf (stderr, "parsing arguments failed\n"); return -2; } /* Use FTW_ACTIONRETVAL to take decision on what to do depending upon */ /* the return value of the callback function */ /* (process_entry in this case) */ ret = nftw (arequal_config.test_directory, process_entry, 30, FTW_ACTIONRETVAL|FTW_PHYS|FTW_MOUNT); if (ret != 0) { fprintf (stderr, "ftw (%s) returned %d (%s), terminating\n", argv[1], ret, strerror (errno)); return 1; } display_stats (stdout); if (arequal_config.ignored_directory) { for (i = 0; i < arequal_config.directories_ignored; i++) { if (arequal_config.ignored_directory[i]) free (arequal_config.ignored_directory[i]); } free (arequal_config.ignored_directory); } return 0; }
static int monitor_task(void *arg) { struct thermostat* th = arg; while(!kthread_should_stop()) { if (unlikely(freezing(current))) refrigerator(); msleep_interruptible(2000); #ifdef DEBUG DumpTachoRegisters(); #endif read_sensors(th); update_fan_speed(th); #ifdef DEBUG /* be carefule with the stats displayed. The Fan Counter value depends * on what value is written in the register during the read sensors * call. If its in temperature read setting, the fan counter and hence * the rpm will be WRONG */ display_stats(th); #endif } return 0; }
void veh_interact::do_rename(int reason) { std::string name = string_input_popup("Enter new vehicle name", 20); (veh->name = name); werase(w_stats); werase(w_grid); display_stats (); display_veh (); }
static void after(const char *msg) { time_t diff; CHECK(gettimeofday(&tv_after, NULL) != -1); diff = tv_after.tv_sec - tv_before.tv_sec; if (diff >= 8) { printf("\nrndrm99: the following fn took more than 8 seconds: %s (took %u secs)\n",msg,(unsigned) diff); fflush(stdout); display_stats(); } }
/** * Handles renaming a vehicle. * @param reason Unused. */ void veh_interact::do_rename(int reason) { std::string name = string_input_popup(_("Enter new vehicle name:"), 20); if(name.length() > 0) { (veh->name = name); } werase(w_stats); werase(w_grid); display_stats (); display_veh (); }
int expose_hook(t_env *e) { if (ispressed(e->key)) e->scene.progressive_loading ? raytracing_progressive(e, e->cam) : start_raytracing(e); if (e->cam->type == STEREOSCOPIC) mlx_put_image_to_window(e->mlx, e->win.adr, e->cam->stereo.adr, 0, 0); else mlx_put_image_to_window(e->mlx, e->win.adr, e->cam->img.adr, 0, 0); e->key[STAT] ? display_stats(e) : 0; return (0); }
int display(t_context *c) { move_myass(c, c->keyboard); init_display(c); draw_flush_image(c->x, c->x->img); display_stats(c); mlx_put_image_to_window(c->x->mlxptr, c->x->winptr, c->map.tex[1].img, (c->x->width / 2) - c->map.tex[1].width / 2, c->x->height - c->map.tex[1].height); return (0); }
static void stats_display_layout(uint8_t in_place) { uint8_t cur_stats_height; cur_stats_height = current_screen->get_height(); cur_stats_height = cur_stats_height > max_n_lines? max_n_lines: cur_stats_height; display_lock(); if (!in_place) { // moving existing windows does not work delwin(win_txt); delwin(win_general); delwin(win_title); delwin(win_tabs); delwin(win_cmd); delwin(win_txt); delwin(win_help); clear(); } if (!in_place) { win_stat = create_subwindow(cur_stats_height + 2, 0, 4, 0); win_tabs = create_subwindow(1, 0, 1, 0); win_general = create_subwindow(2, 0, 2, 0); win_title = create_subwindow(1, 0, 0, 0); win_cmd = create_subwindow(1, 0, cur_stats_height + 2 + 4, 0); win_txt_height = LINES - cur_stats_height - 2 - 3 - 3; win_txt = create_subwindow(win_txt_height, 0, cur_stats_height + 4 + 3, 0); win_help = create_subwindow(1, 0, LINES - 1, 0); } draw_title(); draw_general_frame(); /* Command line */ wbkgd(win_cmd, COLOR_PAIR(BLACK_ON_YELLOW)); idlok(win_cmd, FALSE); /* Move cursor at insertion point */ leaveok(win_cmd, FALSE); draw_status_bar(); draw_log_window(); /* Draw everything to the screen */ refresh(); current_screen->draw_frame(&screen_state); display_unlock(); refresh_cmd_win(); display_stats(); }
int main(){ int menu=0; List* user_list = (List*)malloc(sizeof(List)); tweetList* word_list = (tweetList*)malloc(sizeof(tweetList)); //list_init(user_list); while(menu!=99){ puts("\t***************\t Menu \t*****************"); puts("\t0. Read data files"); puts("\t1. display statistics"); puts("\t2. Top 5 most tweeted words"); puts("\t3. Top 5 most tweeted users"); puts("\t4. Find users who tweeted a word (e.g., ’연세대’)"); puts("\t5. Find all people who are friends of the above users"); puts("\t6. Delete all mentions of a word"); puts("\t7. Delete all users who mentioned a word"); puts("\t8. Find strongly connected components"); puts("\t9. Find shortest path from a given user"); printf("\t99. Quit\n"); puts("\t********************************************"); printf("Select menu : "); scanf("%d", &menu); switch(menu){ case 0: read_data_file(user_list, word_list); break; case 1: display_stats(user_list, word_list); break; case 99: printf("Quit this program.\n"); return; default: puts("Wrong Input!\n. Select menu again."); } } return 0; }
/** * Handles renaming a vehicle. * @param reason Unused. */ void veh_interact::do_rename(task_reason reason) { std::string name = string_input_popup(_("Enter new vehicle name:"), 20); if(name.length() > 0) { (veh->name = name); if (veh->tracking_on) { g->cur_om->vehicles[veh->om_id].name = name; } } werase(w_stats); werase(w_grid); display_stats (); display_veh (); }
int inexact_newton(int , char **) { typedef double value_type; typedef std::string key_type; typedef std::map<key_type,std::vector<value_type> > stats_type; stats_type stats; const int size = 2; InexactNewtonMethod<value_type,1000,100> newton(size); function_type<2> F; value_type x[size] = {1,1}; newton ( F,x,1e-16f,1e-13f, &stats ); display_stats(stats); return 0; }
bool ORSA(const std::vector<Match>& vec_matchings, int w1,int h1, int w2,int h2, double& precision, libNumerics::matrix<double>& H, std::vector<size_t>& vec_inliers,bool h**o) { const size_t n = vec_matchings.size(); if(n < 5) { std::cerr << "Error: ORSA needs 5 matches or more to proceed" <<std::endl; return false; } libNumerics::matrix<double> xA(2,n), xB(2,n); for (size_t i=0; i < n; ++i) { xA(0,i) = vec_matchings[i].x1; xA(1,i) = vec_matchings[i].y1; xB(0,i) = vec_matchings[i].x2; xB(1,i) = vec_matchings[i].y2; } std::auto_ptr< orsa::OrsaModel > modelEstimator; if(h**o){ modelEstimator = std::auto_ptr< orsa::HomographyModel >(new orsa::HomographyModel(xA, w1, h1, xB, w2, h2, true)); }else{ //Fundamental modelEstimator = std::auto_ptr< orsa::FundamentalModel >(new orsa::FundamentalModel(xA, w1, h1, xB, w2, h2, true)); } if(modelEstimator->orsa(vec_inliers, 2000, &precision, &H, false)>0.0) return false; //std::cout << "Before refinement: "; //display_stats(vec_matchings, vec_inliers, H,h**o); if( modelEstimator->ComputeModel(vec_inliers,&H) ) // Re-estimate with all inliers { std::cout << "After refinement: "; display_stats(vec_matchings, vec_inliers, H,h**o); } else std::cerr << "Warning: error in refinement, result is suspect" <<std::endl; return true; }
/** * Implements the scenario selection popup. */ void statistics_dialog::do_scene_selection() { // Prepare a list of scenario names. std::vector<std::string> names; for ( size_t i = 0; i != scenarios_.size(); ++i ) names.push_back(*scenarios_[i].first); // Let the player choose a scenario. SDL_Rect const &loc = scene_btn_->location(); size_t new_scenario = gui::show_dialog(get_video(), NULL, "", "", gui::MESSAGE, &names, NULL, "", NULL, -1, NULL, loc.x, loc.y + loc.h); if ( new_scenario != scenario_index_ && new_scenario < scenarios_.size() ) { // Switch the displayed data to the selected scenario. scenario_index_ = new_scenario; scene_btn_->set_label(*scenarios_[new_scenario].first); display_stats(false); } }
/* Create an empty sub-directory or small file in the current directory */ static int64_t create_entry(char *return_name) { int fd; char name[256]; int64_t res; for (;;) { sprintf(name, "%u", (unsigned) tests_random_no(10000000)); before(); fd = open(name, O_RDONLY); after("open (create_entry)"); if (fd == -1) break; before(); close(fd); after("close (create_entry)"); } if (return_name) strcpy(return_name, name); if (tests_random_no(2)) { res = create_file(name, tests_random_no(4096)); if (res > 0) files_created += 1; return res; } else { before(); if (mkdir(name, 0777) == -1) { CHECK(errno == ENOSPC); after("mkdir"); errno = 0; fprintf(stderr,"\nrndrm99: mkdir failed with ENOSPC\n");fflush(stderr); display_stats(); return 0; } after("mkdir"); dirs_created += 1; return TESTS_EMPTY_DIR_SIZE; } }
bool NormalGame::handle_key(int k) { STACKTRACE; switch (k >> 8) { default: { return Game::handle_key(k); } break; case KEY_F5: { display_stats(); return true; } break; case KEY_F7: { if (log->type == Log::log_normal) Game::handle_key(k); return true; } break; case KEY_F9: { if (log->type != Log::log_normal) return false; message.out("MUHAHAHAHAHA!!!!", 5000, 12); add(new Planet(random(size), meleedata.planetSprite, random(meleedata.planetSprite->frames()))); return true; } break; //don't use hardwired normal keys case KEY_H: if ((k & 255) == 'H'-'A'+1) indhealthtoggle = ~indhealthtoggle; break; case KEY_T: if ((k & 255) == 'T'-'A'+1) indteamtoggle = ~indteamtoggle; break; } return false; }
/* Write size random bytes into file descriptor fd at the current position, returning the number of bytes actually written */ static uint64_t fill_file(int fd, uint64_t size) { ssize_t written; size_t sz; unsigned start = 0, length; uint64_t remains; uint64_t actual_size = 0; init_write_buffer(); remains = size; while (remains > 0) { length = WRITE_BUFFER_SIZE - start; if (remains > length) sz = length; else sz = (size_t) remains; before(); written = write(fd, write_buffer + start, sz); if (written <= 0) { CHECK(errno == ENOSPC); /* File system full */ errno = 0; after("write"); fprintf(stderr,"\nrndrm99: write failed with ENOSPC\n");fflush(stderr); display_stats(); break; } after("write"); remains -= written; actual_size += written; if ((size_t) written == sz) start = 0; else start += written; } return actual_size; }
int main(int argc, char *argv[]) { bool log_read = false; int select_cluster = -1, select_proc = -1; myDistro->Init( argc, argv ); if (argc == 1) { fprintf(stderr, usage, argv[0]); exit(1); } for (int i=1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'a': select_cluster = select_proc = -1; evict_only = false; break; case 'j': { i++; if (1 != sscanf(argv[i], "%d", &select_cluster)) select_cluster = -1; char *proc_str = strchr(argv[i], '.'); if (proc_str) { if (1 != sscanf(proc_str+1, "%d", &select_proc)) select_proc = -1; } break; } case 't': { totals_only = true; break; } case 'd': { debug_mode = true; break; } case 'e': { evict_only = true; break; } case 'r': { raw_data = true; break; } case 'h': { if (argv[i][2] == 'o') { avoid_dns = false; } else { fprintf(stderr, usage, argv[0]); exit(0); } break; } default: fprintf(stderr, usage, argv[0]); exit(1); } } else { if (access(argv[i], R_OK) < 0) { fprintf(stderr, "Can't access file: %s (errno=%d)\n", argv[i], errno); } else { read_log(argv[i], select_cluster, select_proc); log_read = true; } } } if (log_read && !raw_data) { printf("\n"); display_stats(); } return 0; }
// //========================================================================= // int main(int argc, char **argv) { int j; // Set sane defaults modesInitConfig(); signal(SIGINT, sigintHandler); // Define Ctrl/C handler (exit program) // Parse the command line options for (j = 1; j < argc; j++) { int more = j+1 < argc; // There are more arguments if (!strcmp(argv[j],"--device-index") && more) { #ifndef NORTLSDR Modes.dev_index = verbose_device_search(argv[++j]); #else assert(!"Compiled without librtlsdr support"); #endif } else if (!strcmp(argv[j],"--gain") && more) { Modes.gain = (int) (atof(argv[++j])*10); // Gain is in tens of DBs } else if (!strcmp(argv[j],"--enable-agc")) { Modes.enable_agc++; } else if (!strcmp(argv[j],"--freq") && more) { Modes.freq = (int) strtoll(argv[++j],NULL,10); } else if (!strcmp(argv[j],"--ifile") && more) { Modes.filename = strdup(argv[++j]); } else if (!strcmp(argv[j],"--fix")) { Modes.nfix_crc = 1; } else if (!strcmp(argv[j],"--no-fix")) { Modes.nfix_crc = 0; } else if (!strcmp(argv[j],"--no-crc-check")) { Modes.check_crc = 0; } else if (!strcmp(argv[j],"--phase-enhance")) { Modes.phase_enhance = 1; } else if (!strcmp(argv[j],"--raw")) { Modes.raw = 1; } else if (!strcmp(argv[j],"--net")) { Modes.net = 1; } else if (!strcmp(argv[j],"--modeac")) { Modes.mode_ac = 1; } else if (!strcmp(argv[j],"--net-beast")) { Modes.beast = 1; } else if (!strcmp(argv[j],"--net-only")) { Modes.net = 1; Modes.net_only = 1; } else if (!strcmp(argv[j],"--net-heartbeat") && more) { Modes.net_heartbeat_rate = atoi(argv[++j]) * 15; } else if (!strcmp(argv[j],"--net-ro-size") && more) { Modes.net_output_raw_size = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-ro-rate") && more) { Modes.net_output_raw_rate = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-ro-port") && more) { if (Modes.beast) // Required for legacy backward compatibility {Modes.net_output_beast_port = atoi(argv[++j]);;} else {Modes.net_output_raw_port = atoi(argv[++j]);} } else if (!strcmp(argv[j],"--net-ri-port") && more) { Modes.net_input_raw_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bo-port") && more) { Modes.net_output_beast_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bi-port") && more) { Modes.net_input_beast_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-bind-address") && more) { Modes.net_bind_address = strdup(argv[++j]); } else if (!strcmp(argv[j],"--net-http-port") && more) { Modes.net_http_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-sbs-port") && more) { Modes.net_output_sbs_port = atoi(argv[++j]); } else if (!strcmp(argv[j],"--net-buffer") && more) { Modes.net_sndbuf_size = atoi(argv[++j]); } else if (!strcmp(argv[j],"--onlyaddr")) { Modes.onlyaddr = 1; } else if (!strcmp(argv[j],"--metric")) { Modes.metric = 1; } else if (!strcmp(argv[j],"--aggressive")) { Modes.nfix_crc = MODES_MAX_BITERRORS; } else if (!strcmp(argv[j],"--interactive")) { Modes.interactive = 1; } else if (!strcmp(argv[j],"--interactive-rows") && more) { Modes.interactive_rows = atoi(argv[++j]); } else if (!strcmp(argv[j],"--interactive-ttl") && more) { Modes.interactive_display_ttl = atoi(argv[++j]); } else if (!strcmp(argv[j],"--lat") && more) { Modes.fUserLat = atof(argv[++j]); } else if (!strcmp(argv[j],"--lon") && more) { Modes.fUserLon = atof(argv[++j]); } else if (!strcmp(argv[j],"--debug") && more) { char *f = argv[++j]; while(*f) { switch(*f) { case 'D': Modes.debug |= MODES_DEBUG_DEMOD; break; case 'd': Modes.debug |= MODES_DEBUG_DEMODERR; break; case 'C': Modes.debug |= MODES_DEBUG_GOODCRC; break; case 'c': Modes.debug |= MODES_DEBUG_BADCRC; break; case 'p': Modes.debug |= MODES_DEBUG_NOPREAMBLE; break; case 'n': Modes.debug |= MODES_DEBUG_NET; break; case 'j': Modes.debug |= MODES_DEBUG_JS; break; default: fprintf(stderr, "Unknown debugging flag: %c\n", *f); exit(1); break; } f++; } } else if (!strcmp(argv[j],"--stats")) { Modes.stats = -1; } else if (!strcmp(argv[j],"--stats-every") && more) { Modes.stats = atoi(argv[++j]); } else if (!strcmp(argv[j],"--snip") && more) { snipMode(atoi(argv[++j])); exit(0); } else if (!strcmp(argv[j],"--help")) { showHelp(); exit(0); } else if (!strcmp(argv[j],"--ppm") && more) { Modes.ppm_error = atoi(argv[++j]); } else if (!strcmp(argv[j],"--quiet")) { Modes.quiet = 1; } else if (!strcmp(argv[j],"--mlat")) { Modes.mlat = 1; } else if (!strcmp(argv[j],"--interactive-rtl1090")) { Modes.interactive = 1; Modes.interactive_rtl1090 = 1; } else { fprintf(stderr, "Unknown or not enough arguments for option '%s'.\n\n", argv[j]); showHelp(); exit(1); } } #ifdef _WIN32 // Try to comply with the Copyright license conditions for binary distribution if (!Modes.quiet) {showCopyright();} #endif #ifndef _WIN32 // Setup for SIGWINCH for handling lines if (Modes.interactive) {signal(SIGWINCH, sigWinchCallback);} #endif // Initialization modesInit(); if (Modes.net_only) { fprintf(stderr,"Net-only mode, no RTL device or file open.\n"); } else if (Modes.filename == NULL) { #ifndef NORTLSDR modesInitRTLSDR(); #else assert(!"Compiled without librtlsdr support"); #endif } else { if (Modes.filename[0] == '-' && Modes.filename[1] == '\0') { Modes.fd = STDIN_FILENO; } else if ((Modes.fd = open(Modes.filename, #ifdef _WIN32 (O_RDONLY | O_BINARY) #else (O_RDONLY) #endif )) == -1) { perror("Opening data file"); exit(1); } } if (Modes.net) modesInitNet(); // If the user specifies --net-only, just run in order to serve network // clients without reading data from the RTL device while (Modes.net_only) { if (Modes.exit) exit(0); // If we exit net_only nothing further in main() backgroundTasks(); usleep(100000); } // Create the thread that will read the data from the device. pthread_create(&Modes.reader_thread, NULL, readerThreadEntryPoint, NULL); pthread_mutex_lock(&Modes.data_mutex); while (Modes.exit == 0) { if (Modes.iDataReady == 0) { pthread_cond_wait(&Modes.data_cond,&Modes.data_mutex); // This unlocks Modes.data_mutex, and waits for Modes.data_cond continue; // Once (Modes.data_cond) occurs, it locks Modes.data_mutex } // Modes.data_mutex is Locked, and (Modes.iDataReady != 0) if (Modes.iDataReady) { // Check we have new data, just in case!! Modes.iDataOut &= (MODES_ASYNC_BUF_NUMBER-1); // Just incase // Translate the next lot of I/Q samples into Modes.magnitude computeMagnitudeVector(Modes.pData[Modes.iDataOut]); Modes.stSystemTimeBlk = Modes.stSystemTimeRTL[Modes.iDataOut]; // Update the input buffer pointer queue Modes.iDataOut = (MODES_ASYNC_BUF_NUMBER-1) & (Modes.iDataOut + 1); Modes.iDataReady = (MODES_ASYNC_BUF_NUMBER-1) & (Modes.iDataIn - Modes.iDataOut); // If we lost some blocks, correct the timestamp if (Modes.iDataLost) { Modes.timestampBlk += (MODES_ASYNC_BUF_SAMPLES * 6 * Modes.iDataLost); Modes.stat_blocks_dropped += Modes.iDataLost; Modes.iDataLost = 0; } // It's safe to release the lock now pthread_cond_signal (&Modes.data_cond); pthread_mutex_unlock(&Modes.data_mutex); // Process data after releasing the lock, so that the capturing // thread can read data while we perform computationally expensive // stuff at the same time. detectModeS(Modes.magnitude, MODES_ASYNC_BUF_SAMPLES); // Update the timestamp ready for the next block Modes.timestampBlk += (MODES_ASYNC_BUF_SAMPLES*6); Modes.stat_blocks_processed++; } else { pthread_cond_signal (&Modes.data_cond); pthread_mutex_unlock(&Modes.data_mutex); } backgroundTasks(); pthread_mutex_lock(&Modes.data_mutex); } // If --stats were given, print statistics if (Modes.stats) { display_stats(); } if (Modes.filename == NULL && !Modes.net_only) { #ifndef NORTLSDR rtlsdr_cancel_async(Modes.dev); // Cancel rtlsdr_read_async will cause data input thread to terminate cleanly rtlsdr_close(Modes.dev); #endif } pthread_cond_destroy(&Modes.data_cond); // Thread cleanup pthread_mutex_destroy(&Modes.data_mutex); pthread_join(Modes.reader_thread,NULL); // Wait on reader thread exit #ifndef _WIN32 pthread_exit(0); #else return (0); #endif }
/** * Creates a veh_interact window based on the given parameters. * @param v The vehicle the player is interacting with. * @param x The x-coordinate of the square the player is 'e'xamining. * @param y The y-coordinate of the square the player is 'e'xamining. */ void veh_interact::exec (game *gm, vehicle *v, int x, int y) { g = gm; veh = v; // x1 x2 // y1 ----+------+-- // | | // y2 ----+------+ // | // | winw1 = 12; winw2 = 35; winh1 = 3; winh2 = 12; winw12 = winw1 + winw2 + 1; winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 2; winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2; winh23 = winh2 + winh3 + 1; winx1 = winw1; winx2 = winw1 + winw2 + 1; winy1 = winh1; winy2 = winh1 + winh2 + 1; // changed FALSE value to 1, to keep w_border from starting at a negative x,y const int iOffsetX = (TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 1; const int iOffsetY = (TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 1; page_size = winh23; // h w y x WINDOW *w_border= newwin(FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX); w_grid = newwin(FULL_SCREEN_HEIGHT -2, FULL_SCREEN_WIDTH-2, iOffsetY, iOffsetX); w_mode = newwin(1, FULL_SCREEN_WIDTH-2, iOffsetY, iOffsetX); w_msg = newwin(winh1 - 1, FULL_SCREEN_WIDTH-2, 1 + iOffsetY, iOffsetX); w_disp = newwin(winh2-1, winw1, winy1 + 1 + iOffsetY, iOffsetX); w_parts = newwin(winh2-1, winw2, winy1 + 1 + iOffsetY, winx1 + 1 + iOffsetX); w_stats = newwin(winh3-1, winw12, winy2 + iOffsetY, iOffsetX); w_list = newwin(winh23, winw3, winy1 + 1 + iOffsetY, winx2 + 1 + iOffsetX); wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); mvwputch(w_border, 16, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, 4, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, 4, FULL_SCREEN_WIDTH-1, c_ltgray, LINE_XOXX); // -| mvwputch(w_border, 24, 49, c_ltgray, LINE_XXOX); wrefresh(w_border); for (int i = 0; i < FULL_SCREEN_HEIGHT; i++) { mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2-1? LINE_XOXX : LINE_XOXO); if (i >= winy1 && i < winy2) { mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } } for (int i = 0; i < FULL_SCREEN_WIDTH; i++) { mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX)); if (i < winx2) { mvwputch(w_grid, winy2-1, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX); } } wrefresh(w_grid); crafting_inv = gm->crafting_inventory(&gm->u); int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use; int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("welder_crude", 1) && crafting_inv.has_charges("welder_crude", charges_crude)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/20)); has_jack = crafting_inv.has_amount("jack", 1); has_siphon = crafting_inv.has_amount("hose", 1); has_wheel = crafting_inv.has_amount( "wheel", 1 ) || crafting_inv.has_amount( "wheel_wide", 1 ) || crafting_inv.has_amount( "wheel_bicycle", 1 ) || crafting_inv.has_amount( "wheel_motorbike", 1 ) || crafting_inv.has_amount( "wheel_small", 1 ); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (dx, dy, ch); if (ch == KEY_ESCAPE || ch == 'q' ) { finish = true; } else { if (dx != -2 && (dx || dy) && cursor_x + dx >= -6 && cursor_x + dx < 6 && cursor_y + dy >= -6 && cursor_y + dy < 6) { move_cursor(dx, dy); } else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; case 's': do_siphon(mval); break; case 'c': do_tirechange(mval); break; case 'd': do_drain(mval); break; } if (sel_cmd != ' ') { finish = true; } display_mode (' '); } } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }
// //========================================================================= // // This function is called a few times every second by main in order to // perform tasks we need to do continuously, like accepting new clients // from the net, refreshing the screen in interactive mode, and so forth // void backgroundTasks(void) { static uint64_t next_stats_display; static uint64_t next_stats_update; static uint64_t next_json, next_history; uint64_t now = mstime(); icaoFilterExpire(); trackPeriodicUpdate(); if (Modes.net) { modesNetPeriodicWork(); } // Refresh screen when in interactive mode if (Modes.interactive) { interactiveShowData(); } // always update end time so it is current when requests arrive Modes.stats_current.end = now; if (now >= next_stats_update) { int i; if (next_stats_update == 0) { next_stats_update = now + 60000; } else { Modes.stats_latest_1min = (Modes.stats_latest_1min + 1) % 15; Modes.stats_1min[Modes.stats_latest_1min] = Modes.stats_current; add_stats(&Modes.stats_current, &Modes.stats_alltime, &Modes.stats_alltime); add_stats(&Modes.stats_current, &Modes.stats_periodic, &Modes.stats_periodic); reset_stats(&Modes.stats_5min); for (i = 0; i < 5; ++i) add_stats(&Modes.stats_1min[(Modes.stats_latest_1min - i + 15) % 15], &Modes.stats_5min, &Modes.stats_5min); reset_stats(&Modes.stats_15min); for (i = 0; i < 15; ++i) add_stats(&Modes.stats_1min[i], &Modes.stats_15min, &Modes.stats_15min); reset_stats(&Modes.stats_current); Modes.stats_current.start = Modes.stats_current.end = now; if (Modes.json_dir) writeJsonToFile("stats.json", generateStatsJson); next_stats_update += 60000; } } if (Modes.stats && now >= next_stats_display) { if (next_stats_display == 0) { next_stats_display = now + Modes.stats; } else { add_stats(&Modes.stats_periodic, &Modes.stats_current, &Modes.stats_periodic); display_stats(&Modes.stats_periodic); reset_stats(&Modes.stats_periodic); next_stats_display += Modes.stats; } } if (Modes.json_dir && now >= next_json) { writeJsonToFile("aircraft.json", generateAircraftJson); next_json = now + Modes.json_interval; } if ((Modes.json_dir || Modes.net_http_port) && now >= next_history) { int rewrite_receiver_json = (Modes.json_aircraft_history[HISTORY_SIZE-1].content == NULL); free(Modes.json_aircraft_history[Modes.json_aircraft_history_next].content); // might be NULL, that's OK. Modes.json_aircraft_history[Modes.json_aircraft_history_next].content = generateAircraftJson("/data/aircraft.json", &Modes.json_aircraft_history[Modes.json_aircraft_history_next].clen); if (Modes.json_dir) { char filebuf[PATH_MAX]; snprintf(filebuf, PATH_MAX, "history_%d.json", Modes.json_aircraft_history_next); writeJsonToFile(filebuf, generateHistoryJson); } Modes.json_aircraft_history_next = (Modes.json_aircraft_history_next+1) % HISTORY_SIZE; if (rewrite_receiver_json) writeJsonToFile("receiver.json", generateReceiverJson); // number of history entries changed next_history = now + HISTORY_INTERVAL; } }
static void display_total_stats(void) { struct stats added; add_stats(&Modes.stats_alltime, &Modes.stats_current, &added); display_stats(&added); }
// Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) { LLFastTimer t(LLFastTimer::FTM_RENDER); if (LLPipeline::sRenderFrameTest) { send_agent_pause(); } gSnapshot = for_snapshot; LLGLSDefault gls_default; LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); LLVertexBuffer::unbind(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); gPipeline.disableLights(); // Don't draw if the window is hidden or minimized. // In fact, must explicitly check the minimized state before drawing. // Attempting to draw into a minimized window causes a GL error. JC if ( !gViewerWindow->getActive() || !gViewerWindow->mWindow->getVisible() || gViewerWindow->mWindow->getMinimized() ) { // Clean up memory the pools may have allocated if (rebuild) { gFrameStats.start(LLFrameStats::REBUILD); gPipeline.rebuildPools(); } gViewerWindow->returnEmptyPicks(); return; } gViewerWindow->checkSettings(); { LLFastTimer ftm(LLFastTimer::FTM_PICK); LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); gViewerWindow->performPick(); } LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); LLGLState::checkStates(); LLGLState::checkTextureChannels(); ////////////////////////////////////////////////////////// // // Logic for forcing window updates if we're in drone mode. // if (gNoRender) { #if LL_WINDOWS static F32 last_update_time = 0.f; if ((gFrameTimeSeconds - last_update_time) > 1.f) { InvalidateRect((HWND)gViewerWindow->getPlatformWindow(), NULL, FALSE); last_update_time = gFrameTimeSeconds; } #elif LL_DARWIN // MBW -- Do something clever here. #endif // Not actually rendering, don't bother. return; } // // Bail out if we're in the startup state and don't want to try to // render the world. // if (LLStartUp::getStartupState() < STATE_STARTED) { LLAppViewer::instance()->pingMainloopTimeout("Display:Startup"); display_startup(); return; } //LLGLState::verify(FALSE); ///////////////////////////////////////////////// // // Update GL Texture statistics (used for discard logic?) // LLAppViewer::instance()->pingMainloopTimeout("Display:TextureStats"); gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS); stop_glerror(); LLImageGL::updateStats(gFrameTimeSeconds); LLVOAvatar::sRenderName = gSavedSettings.getS32("RenderName"); LLVOAvatar::sRenderGroupTitles = !gSavedSettings.getBOOL("RenderHideGroupTitleAll"); gPipeline.mBackfaceCull = TRUE; gFrameCount++; gRecentFrameCount++; if (gFocusMgr.getAppHasFocus()) { gForegroundFrameCount++; } ////////////////////////////////////////////////////////// // // Display start screen if we're teleporting, and skip render // if (gTeleportDisplay) { LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. S32 attach_count = 0; if (gAgent.getAvatarObject()) { attach_count = gAgent.getAvatarObject()->getAttachmentCount(); } F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count; F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32(); F32 teleport_percent = teleport_elapsed * (100.f / teleport_save_time); if( (gAgent.getTeleportState() != LLAgent::TELEPORT_START) && (teleport_percent > 100.f) ) { // Give up. Don't keep the UI locked forever. gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); gAgent.setTeleportMessage(std::string()); } const std::string& message = gAgent.getTeleportMessage(); switch( gAgent.getTeleportState() ) { case LLAgent::TELEPORT_START: // Transition to REQUESTED. Viewer has sent some kind // of TeleportRequest to the source simulator gTeleportDisplayTimer.reset(); gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressPercent(0); gAgent.setTeleportState( LLAgent::TELEPORT_REQUESTED ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["requesting"]); break; case LLAgent::TELEPORT_REQUESTED: // Waiting for source simulator to respond gViewerWindow->setProgressPercent( llmin(teleport_percent, 37.5f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_MOVING: // Viewer has received destination location from source simulator gViewerWindow->setProgressPercent( llmin(teleport_percent, 75.f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_START_ARRIVAL: // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator gTeleportArrivalTimer.reset(); gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate gViewerWindow->setProgressPercent(75.f); gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["arriving"]); gImageList.mForceResetTextureStats = TRUE; gAgent.resetView(TRUE, TRUE); break; case LLAgent::TELEPORT_ARRIVING: // Make the user wait while content "pre-caches" { F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / TELEPORT_ARRIVAL_DELAY); if( arrival_fraction > 1.f ) { arrival_fraction = 1.f; LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } gViewerWindow->setProgressCancelButtonVisible(FALSE, std::string("Cancel")); //TODO: Translate gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); gViewerWindow->setProgressString(message); } break; case LLAgent::TELEPORT_LOCAL: // Short delay when teleporting in the same sim (progress screen active but not shown - did not // fall-through from TELEPORT_START) { if( gTeleportDisplayTimer.getElapsedTimeF32() > TELEPORT_LOCAL_DELAY ) { LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } } break; case LLAgent::TELEPORT_NONE: // No teleport in progress gViewerWindow->setShowProgress(FALSE); gTeleportDisplay = FALSE; break; default: break; } } else if(LLAppViewer::instance()->logoutRequestSent()) { LLAppViewer::instance()->pingMainloopTimeout("Display:Logout"); F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime; if (percent_done > 100.f) { percent_done = 100.f; } if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } else if (gRestoreGL) { LLAppViewer::instance()->pingMainloopTimeout("Display:RestoreGL"); F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME; if( percent_done > 100.f ) { gViewerWindow->setShowProgress(FALSE); gRestoreGL = FALSE; } else { if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } } ////////////////////////// // // Prepare for the next frame // ///////////////////////////// // // Update the camera // // LLAppViewer::instance()->pingMainloopTimeout("Display:Camera"); LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield); LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); ////////////////////////// // // clear the next buffer // (must follow dynamic texture writing since that uses the frame buffer) // if (gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); render_ui(); render_disconnected_background(); } ////////////////////////// // // Set rendering options // // LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); stop_glerror(); /////////////////////////////////////// // // Slam lighting parameters back to our defaults. // Note that these are not the same as GL defaults... stop_glerror(); F32 one[4] = {1.f, 1.f, 1.f, 1.f}; glLightModelfv (GL_LIGHT_MODEL_AMBIENT,one); stop_glerror(); ///////////////////////////////////// // // Render // // Actually push all of our triangles to the screen. // // do render-to-texture stuff here if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) { LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); LLFastTimer t(LLFastTimer::FTM_UPDATE_TEXTURES); if (LLDynamicTexture::updateAllInstances()) { gGL.setColorMask(true, true); glClear(GL_DEPTH_BUFFER_BIT); } } gViewerWindow->setupViewport(); gPipeline.resetFrameStats(); // Reset per-frame statistics. if (!gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Update"); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { //don't draw hud objects in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); } if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES)) { //don't draw hud particles in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES); } //upkeep gl name pools LLGLNamePool::upkeepPools(); stop_glerror(); display_update_camera(); stop_glerror(); // *TODO: merge these two methods LLHUDManager::getInstance()->updateEffects(); LLHUDObject::updateAll(); stop_glerror(); gFrameStats.start(LLFrameStats::UPDATE_GEOM); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.updateGeom(max_geom_update_time); stop_glerror(); gFrameStats.start(LLFrameStats::UPDATE_CULL); S32 water_clip = 0; if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER) || gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER))) { if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_clip = -1; } else { water_clip = 1; } } LLAppViewer::instance()->pingMainloopTimeout("Display:Cull"); //Increment drawable frame counter LLDrawable::incrementVisible(); LLSpatialGroup::sNoDelete = TRUE; LLPipeline::sUseOcclusion = (!gUseWireframe && LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") && gSavedSettings.getBOOL("UseOcclusion") && gGLManager.mHasOcclusionQuery) ? 2 : 0; if (LLPipeline::sUseOcclusion && LLPipeline::sRenderDeferred) { //force occlusion on for all render types if doing deferred render LLPipeline::sUseOcclusion = 3; } LLPipeline::sFastAlpha = gSavedSettings.getBOOL("RenderFastAlpha"); LLPipeline::sUseFarClip = gSavedSettings.getBOOL("RenderUseFarClip"); LLVOAvatar::sMaxVisible = gSavedSettings.getS32("RenderAvatarMaxVisible"); LLPipeline::sDelayVBUpdate = gSavedSettings.getBOOL("RenderDelayVBUpdate"); S32 occlusion = LLPipeline::sUseOcclusion; if (gDepthDirty) { //depth buffer is invalid, don't overwrite occlusion state LLPipeline::sUseOcclusion = llmin(occlusion, 1); } gDepthDirty = FALSE; LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); static LLCullResult result; gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); stop_glerror(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); BOOL to_texture = !for_snapshot && gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow; LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); { { LLFastTimer ftm(LLFastTimer::FTM_CLIENT_COPY); LLVertexBuffer::clientCopy(0.016); } if (gResizeScreenTexture) { gResizeScreenTexture = FALSE; gPipeline.resizeScreenTexture(); } gGL.setColorMask(true, true); glClearColor(0,0,0,0); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); if (!for_snapshot) { if (gFrameCount > 1) { //for some reason, ATI 4800 series will error out if you //try to generate a shadow before the first frame is through gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); } LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); glh::matrix4f proj = glh_get_current_projection(); glh::matrix4f mod = glh_get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateFreezeCounter() ; LLVOAvatar::updateImpostors(); glh_set_current_projection(proj); glh_set_current_modelview(mod); glMatrixMode(GL_PROJECTION); glLoadMatrixf(proj.m); glMatrixMode(GL_MODELVIEW); glLoadMatrixf(mod.m); gViewerWindow->setupViewport(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); } glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } if (!for_snapshot) { LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); } ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling // // Can put objects onto the retextured list. // // Doing this here gives hardware occlusion queries extra time to complete LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); LLError::LLCallStacks::clear() ; llpushcallstacks ; gFrameStats.start(LLFrameStats::IMAGE_UPDATE); { LLFastTimer t(LLFastTimer::FTM_IMAGE_UPDATE); LLViewerImage::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean()); gBumpImageList.updateImages(); // must be called before gImageList version so that it's textures are thrown out first. F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds; // 50 ms/second decode time max_image_decode_time = llclamp(max_image_decode_time, 0.001f, 0.005f ); // min 1ms/frame, max 5ms/frame) gImageList.updateImages(max_image_decode_time); stop_glerror(); } llpushcallstacks ; /////////////////////////////////// // // StateSort // // Responsible for taking visible objects, and adding them to the appropriate draw orders. // In the case of alpha objects, z-sorts them first. // Also creates special lists for outlines and selected face rendering. // LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort"); { gFrameStats.start(LLFrameStats::STATE_SORT); gPipeline.stateSort(*LLViewerCamera::getInstance(), result); stop_glerror(); if (rebuild) { ////////////////////////////////////// // // rebuildPools // // gFrameStats.start(LLFrameStats::REBUILD); gPipeline.rebuildPools(); stop_glerror(); } } LLPipeline::sUseOcclusion = occlusion; { LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LLFastTimer t(LLFastTimer::FTM_UPDATE_SKY); gSky.updateSky(); } if(gUseWireframe) { glClearColor(0.5f, 0.5f, 0.5f, 0.f); glClear(GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); //// render frontmost floater opaque for occlusion culling purposes //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); //// assumes frontmost floater with focus is opaque //if (frontmost_floaterp && gFocusMgr.childHasKeyboardFocus(frontmost_floaterp)) //{ // glMatrixMode(GL_MODELVIEW); // glPushMatrix(); // { // gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); // glLoadIdentity(); // LLRect floater_rect = frontmost_floaterp->getScreenRect(); // // deflate by one pixel so rounding errors don't occlude outside of floater extents // floater_rect.stretch(-1); // LLRectf floater_3d_rect((F32)floater_rect.mLeft / (F32)gViewerWindow->getWindowWidth(), // (F32)floater_rect.mTop / (F32)gViewerWindow->getWindowHeight(), // (F32)floater_rect.mRight / (F32)gViewerWindow->getWindowWidth(), // (F32)floater_rect.mBottom / (F32)gViewerWindow->getWindowHeight()); // floater_3d_rect.translate(-0.5f, -0.5f); // glTranslatef(0.f, 0.f, -LLViewerCamera::getInstance()->getNear()); // glScalef(LLViewerCamera::getInstance()->getNear() * LLViewerCamera::getInstance()->getAspect() / sinf(LLViewerCamera::getInstance()->getView()), LLViewerCamera::getInstance()->getNear() / sinf(LLViewerCamera::getInstance()->getView()), 1.f); // gGL.color4fv(LLColor4::white.mV); // gGL.begin(LLVertexBuffer::QUADS); // { // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mBottom, 0.f); // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mBottom, 0.f); // } // gGL.end(); // glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // } // glPopMatrix(); //} LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLPipeline::updateRenderDeferred(); stop_glerror(); if (to_texture) { gGL.setColorMask(true, true); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.mDeferredScreen.bindTarget(); gPipeline.mDeferredScreen.clear(); } else { gPipeline.mScreen.bindTarget(); gPipeline.mScreen.clear(); } gGL.setColorMask(true, false); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderGeom"); if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) && !gRestoreGL) { gGL.setColorMask(true, false); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); } else { gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); } gGL.setColorMask(true, true); //store this frame's modelview matrix for use //when rendering next frame's occlusion queries for (U32 i = 0; i < 16; i++) { gGLLastModelView[i] = gGLModelView[i]; } stop_glerror(); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); if (to_texture) { if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.mDeferredScreen.flush(); } else { gPipeline.mScreen.flush(); } } /// We copy the frame buffer straight into a texture here, /// and then display it again with compositor effects. /// Using render to texture would be faster/better, but I don't have a /// grasp of their full display stack just yet. // gPostProcess->apply(gViewerWindow->getWindowDisplayWidth(), gViewerWindow->getWindowDisplayHeight()); if (LLPipeline::sRenderDeferred && !LLPipeline::sUnderWaterRender) { gPipeline.renderDeferredLighting(); } LLPipeline::sUnderWaterRender = FALSE; LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); if (!for_snapshot) { gFrameStats.start(LLFrameStats::RENDER_UI); render_ui(); } LLSpatialGroup::sNoDelete = FALSE; } LLAppViewer::instance()->pingMainloopTimeout("Display:FrameStats"); gFrameStats.start(LLFrameStats::MISC_END); stop_glerror(); if (LLPipeline::sRenderFrameTest) { send_agent_resume(); LLPipeline::sRenderFrameTest = FALSE; } display_stats(); LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); }
void statistics_dialog::action(gui::dialog_process_info &dp_info) { int sel = get_menu().selection(); bool has_details = sel < 5 && sel >= 0 && unit_count_[sel] > 0; detail_btn_->enable(has_details); if(dp_info.double_clicked && has_details) { set_result(sel); } else if(dp_info.new_key_down && !dp_info.key_down) { set_result(gui::CLOSE_DIALOG); } // Prepare the sub-dialog for Statistic Details std::string title; std::vector<std::string> items_sub; switch(result()) { case gui::CLOSE_DIALOG: break; case 0: items_sub = create_unit_table(current_stats().recruits, team_num_); title = _("Recruits"); break; case 1: items_sub = create_unit_table(current_stats().recalls, team_num_); title = _("Recalls"); break; case 2: items_sub = create_unit_table(current_stats().advanced_to, team_num_); title = _("Advancements"); break; case 3: items_sub = create_unit_table(current_stats().deaths, team_num_); title = _("Losses"); break; case 4: // Give kills a (probably) different team color. items_sub = create_unit_table(current_stats().killed, team_num_ == 1 ? 2 : 1); title = _("Kills"); break; case BUTTON_SCENE: // Scenario selection. do_scene_selection(); set_result(gui::CONTINUE_DIALOG); break; case BUTTON_TOGGLE: // Toggle between campaign and scenario stats. display_stats(!use_campaign_); set_result(gui::CONTINUE_DIALOG); break; default: break; } if (items_sub.empty() == false) { gui::dialog d(get_video(), title + " (" + player_name_ + ")", "", gui::CLOSE_ONLY); d.set_menu(items_sub); d.show(); dp_info.clear_buttons(); set_result(gui::CONTINUE_DIALOG); } }
/** * Creates a veh_interact window based on the given parameters. * @param v The vehicle the player is interacting with. * @param x The x-coordinate of the square the player is 'e'xamining. * @param y The y-coordinate of the square the player is 'e'xamining. */ void veh_interact::exec (game *gm, vehicle *v, int x, int y) { veh = v; // winw1 winw2 winw3 // winh1 | | // ------+-------+------ // winh2 | | // ------+-------+------ // winh3 | | // // +-------------------------+ // | w_mode | // | w_msg | // +-------+---------+-------+ // |w_disp | w_parts | w_list| // +-------+---------+-------+ // | w_stats | // +-------------------------+ int winw1 = 12; int winw2 = 35; int winh1 = 3; int winh2 = 13; int winw3 = FULL_SCREEN_WIDTH - winw1 - winw2 - 4; int winh3 = FULL_SCREEN_HEIGHT - winh1 - winh2 - 2; int winx1 = winw1; int winx2 = winw1 + winw2 + 1; int winy1 = winh1; int winy2 = winh1 + winh2 + 1; mode_h = 1; mode_w = FULL_SCREEN_WIDTH - 2; msg_h = winh1 - 1; msg_w = FULL_SCREEN_WIDTH - 2; disp_h = winh2 - 1; disp_w = winw1; parts_h = winh2 - 1; parts_w = winw2; stats_h = winh3 - 1; stats_w = FULL_SCREEN_WIDTH - 2; list_h = winh2 - 1; list_w = winw3; const int iOffsetX = 1 + ((TERMX > FULL_SCREEN_WIDTH) ? (TERMX-FULL_SCREEN_WIDTH)/2 : 0); const int iOffsetY = 1 + ((TERMY > FULL_SCREEN_HEIGHT) ? (TERMY-FULL_SCREEN_HEIGHT)/2 : 0); page_size = list_h; // h w y x WINDOW *w_border = newwin( FULL_SCREEN_HEIGHT, FULL_SCREEN_WIDTH, -1 + iOffsetY, -1 + iOffsetX ); w_grid = newwin( FULL_SCREEN_HEIGHT - 2, FULL_SCREEN_WIDTH - 2, iOffsetY, iOffsetX ); w_mode = newwin( mode_h, mode_w, iOffsetY, iOffsetX ); w_msg = newwin( msg_h, msg_w, mode_h + iOffsetY, iOffsetX ); w_disp = newwin( disp_h, disp_w, mode_h + msg_h + 1 + iOffsetY, iOffsetX ); w_parts = newwin( parts_h, parts_w, mode_h + msg_h + 1 + iOffsetY, disp_w + 1 + iOffsetX ); w_list = newwin( list_h, list_w, mode_h + msg_h + 1 + iOffsetY, disp_w + 1 + parts_w + 1 + iOffsetX ); w_stats = newwin( stats_h, stats_w, mode_h + msg_h + 1 + disp_h + 1 + iOffsetY, iOffsetX ); wborder(w_border, LINE_XOXO, LINE_XOXO, LINE_OXOX, LINE_OXOX, LINE_OXXO, LINE_OOXX, LINE_XXOO, LINE_XOOX ); mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, mode_h + msg_h + 1, 0, c_ltgray, LINE_XXXO); // |- mvwputch(w_border, mode_h + msg_h + 1 + disp_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX); mvwputch(w_border, mode_h + msg_h + 1, FULL_SCREEN_WIDTH - 1, c_ltgray, LINE_XOXX); wrefresh(w_border); // Two lines dividing the three middle sections. for (int i = winy1; i < winy2; i++) { mvwputch(w_grid, i, winx2, c_ltgray, LINE_XOXO); mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } // Two lines dividing the vertical menu sections. for (int i = 0; i < FULL_SCREEN_WIDTH; i++) { mvwputch( w_grid, winy1, i, c_ltgray, LINE_OXOX ); mvwputch( w_grid, winy2-1, i, c_ltgray, LINE_OXOX ); } // Fix up the line intersections. mvwputch( w_grid, winy1, winx1, c_ltgray, LINE_OXXX ); mvwputch( w_grid, winy1, winx2, c_ltgray, LINE_OXXX ); mvwputch( w_grid, winy2 - 1, winx1, c_ltgray, LINE_XXOX ); mvwputch( w_grid, winy2 - 1, winx2, c_ltgray, LINE_XXOX ); wrefresh(w_grid); crafting_inv = g->crafting_inventory(&g->u); int charges = static_cast<it_tool *>(g->itypes["welder"])->charges_per_use; int charges_crude = static_cast<it_tool *>(g->itypes["welder_crude"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("welder_crude", 1) && crafting_inv.has_charges("welder_crude", charges_crude)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/20)); has_jack = crafting_inv.has_amount("jack", 1); has_siphon = crafting_inv.has_amount("hose", 1); has_wheel = crafting_inv.has_amount( "wheel", 1 ) || crafting_inv.has_amount( "wheel_wide", 1 ) || crafting_inv.has_amount( "wheel_bicycle", 1 ) || crafting_inv.has_amount( "wheel_motorbike", 1 ) || crafting_inv.has_amount( "wheel_small", 1 ); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (dx, dy, ch); if (ch == KEY_ESCAPE || ch == 'q' ) { finish = true; } else { if (dx != -2 && (dx || dy) && cursor_x + dx >= -6 && cursor_x + dx < 6 && cursor_y + dy >= -6 && cursor_y + dy < 6) { move_cursor(dx, dy); } else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; case 's': do_siphon(mval); break; case 'c': do_tirechange(mval); break; case 'd': do_drain(mval); break; } if (sel_cmd != ' ') { finish = true; } display_mode (' '); } } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }
// Paint the display! void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, bool tiling) { LLFastTimer t(FTM_RENDER); if (gWindowResized) { //skip render on frames where window has been resized gGL.flush(); glClear(GL_COLOR_BUFFER_BIT); gViewerWindow->getWindow()->swapBuffers(); LLPipeline::refreshCachedSettings(); gPipeline.resizeScreenTexture(); gResizeScreenTexture = FALSE; gWindowResized = FALSE; return; } //Nope /*if (LLPipeline::sRenderDeferred) { //hack to make sky show up in deferred snapshots for_snapshot = FALSE; }*/ if (LLPipeline::sRenderFrameTest) { send_agent_pause(); } gSnapshot = for_snapshot; LLGLSDefault gls_default; LLGLDepthTest gls_depth(GL_TRUE, GL_TRUE, GL_LEQUAL); LLVertexBuffer::unbind(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); stop_glerror(); gPipeline.disableLights(); //reset vertex buffers if needed gPipeline.doResetVertexBuffers(); stop_glerror(); // Don't draw if the window is hidden or minimized. // In fact, must explicitly check the minimized state before drawing. // Attempting to draw into a minimized window causes a GL error. JC if ( !gViewerWindow->getActive() || !gViewerWindow->getWindow()->getVisible() || gViewerWindow->getWindow()->getMinimized() ) { // Clean up memory the pools may have allocated if (rebuild) { gFrameStats.start(LLFrameStats::REBUILD); stop_glerror(); gPipeline.rebuildPools(); stop_glerror(); } stop_glerror(); gViewerWindow->returnEmptyPicks(); stop_glerror(); return; } gViewerWindow->checkSettings(); if(gWindowResized) //Singu Note: gViewerWindow->checkSettings() can call LLViewerWindow::reshape(). If it has then skip this frame. { return; } { LLFastTimer ftm(FTM_PICK); LLAppViewer::instance()->pingMainloopTimeout("Display:Pick"); gViewerWindow->performPick(); } LLAppViewer::instance()->pingMainloopTimeout("Display:CheckStates"); LLGLState::checkStates(); LLGLState::checkTextureChannels(); ////////////////////////////////////////////////////////// // // Logic for forcing window updates if we're in drone mode. // if (gNoRender) { #if LL_WINDOWS static F32 last_update_time = 0.f; if ((gFrameTimeSeconds - last_update_time) > 1.f) { InvalidateRect((HWND)gViewerWindow->getPlatformWindow(), NULL, FALSE); last_update_time = gFrameTimeSeconds; } #elif LL_DARWIN // MBW -- Do something clever here. #endif // Not actually rendering, don't bother. return; } // // Bail out if we're in the startup state and don't want to try to // render the world. // if (LLStartUp::getStartupState() < STATE_STARTED) { LLAppViewer::instance()->pingMainloopTimeout("Display:Startup"); display_startup(); return; } //LLGLState::verify(FALSE); ///////////////////////////////////////////////// // // Update GL Texture statistics (used for discard logic?) // LLAppViewer::instance()->pingMainloopTimeout("Display:TextureStats"); gFrameStats.start(LLFrameStats::UPDATE_TEX_STATS); stop_glerror(); LLImageGL::updateStats(gFrameTimeSeconds); LLVOAvatar::sRenderName = gSavedSettings.getS32("RenderName"); LLVOAvatar::sRenderGroupTitles = !gSavedSettings.getBOOL("RenderHideGroupTitleAll"); gPipeline.mBackfaceCull = TRUE; gFrameCount++; gRecentFrameCount++; if (gFocusMgr.getAppHasFocus()) { gForegroundFrameCount++; } ////////////////////////////////////////////////////////// // // Display start screen if we're teleporting, and skip render // if (gTeleportDisplay) { LLAppViewer::instance()->pingMainloopTimeout("Display:Teleport"); const F32 TELEPORT_ARRIVAL_DELAY = 2.f; // Time to preload the world before raising the curtain after we've actually already arrived. S32 attach_count = 0; if (isAgentAvatarValid()) { attach_count = gAgentAvatarp->getAttachmentCount(); } F32 teleport_save_time = TELEPORT_EXPIRY + TELEPORT_EXPIRY_PER_ATTACHMENT * attach_count; F32 teleport_elapsed = gTeleportDisplayTimer.getElapsedTimeF32(); F32 teleport_percent = teleport_elapsed * (100.f / teleport_save_time); if( (gAgent.getTeleportState() != LLAgent::TELEPORT_START) && (teleport_percent > 100.f) ) { // Give up. Don't keep the UI locked forever. gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); gAgent.setTeleportMessage(std::string()); } static const LLCachedControl<bool> hide_tp_screen("AscentDisableTeleportScreens",false); const std::string& message = gAgent.getTeleportMessage(); switch( gAgent.getTeleportState() ) { case LLAgent::TELEPORT_PENDING: gTeleportDisplayTimer.reset(); if(!hide_tp_screen) gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); gAgent.setTeleportMessage(LLAgent::sTeleportProgressMessages["pending"]); gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["pending"]); break; case LLAgent::TELEPORT_START: // Transition to REQUESTED. Viewer has sent some kind // of TeleportRequest to the source simulator gTeleportDisplayTimer.reset(); if(!hide_tp_screen) gViewerWindow->setShowProgress(TRUE); gViewerWindow->setProgressPercent(llmin(teleport_percent, 0.0f)); gAgent.setTeleportState( LLAgent::TELEPORT_REQUESTED ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["requesting"]); gViewerWindow->setProgressString(LLAgent::sTeleportProgressMessages["requesting"]); break; case LLAgent::TELEPORT_REQUESTED: // Waiting for source simulator to respond gViewerWindow->setProgressPercent( llmin(teleport_percent, 37.5f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_MOVING: // Viewer has received destination location from source simulator gViewerWindow->setProgressPercent( llmin(teleport_percent, 75.f) ); gViewerWindow->setProgressString(message); break; case LLAgent::TELEPORT_START_ARRIVAL: // Transition to ARRIVING. Viewer has received avatar update, etc., from destination simulator gTeleportArrivalTimer.reset(); gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); gViewerWindow->setProgressPercent(75.f); gAgent.setTeleportState( LLAgent::TELEPORT_ARRIVING ); gAgent.setTeleportMessage( LLAgent::sTeleportProgressMessages["arriving"]); gTextureList.mForceResetTextureStats = TRUE; if(!hide_tp_screen) gAgentCamera.resetView(TRUE, TRUE); break; case LLAgent::TELEPORT_ARRIVING: // Make the user wait while content "pre-caches" { F32 arrival_fraction = (gTeleportArrivalTimer.getElapsedTimeF32() / TELEPORT_ARRIVAL_DELAY); if( arrival_fraction > 1.f || hide_tp_screen) { arrival_fraction = 1.f; LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } gViewerWindow->setProgressCancelButtonVisible(FALSE, LLTrans::getString("Cancel")); gViewerWindow->setProgressPercent( arrival_fraction * 25.f + 75.f); gViewerWindow->setProgressString(message); } break; case LLAgent::TELEPORT_LOCAL: // Short delay when teleporting in the same sim (progress screen active but not shown - did not // fall-through from TELEPORT_START) { // <edit> // is this really needed.... I say no. //if( gTeleportDisplayTimer.getElapsedTimeF32() > TELEPORT_LOCAL_DELAY ) // </edit> { LLFirstUse::useTeleport(); gAgent.setTeleportState( LLAgent::TELEPORT_NONE ); } } break; case LLAgent::TELEPORT_NONE: // No teleport in progress gViewerWindow->setShowProgress(FALSE); gTeleportDisplay = FALSE; gTeleportArrivalTimer.reset(); break; default: break; } } else if(LLAppViewer::instance()->logoutRequestSent()) { LLAppViewer::instance()->pingMainloopTimeout("Display:Logout"); F32 percent_done = gLogoutTimer.getElapsedTimeF32() * 100.f / gLogoutMaxTime; if (percent_done > 100.f) { percent_done = 100.f; } if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } else if (gRestoreGL) { LLAppViewer::instance()->pingMainloopTimeout("Display:RestoreGL"); F32 percent_done = gRestoreGLTimer.getElapsedTimeF32() * 100.f / RESTORE_GL_TIME; if( percent_done > 100.f ) { gViewerWindow->setShowProgress(FALSE); gRestoreGL = FALSE; } else { if( LLApp::isExiting() ) { percent_done = 100.f; } gViewerWindow->setProgressPercent( percent_done ); } } // Progressively increase draw distance after TP when required. if (gSavedDrawDistance > 0.0f && gAgent.getTeleportState() == LLAgent::TELEPORT_NONE) { if (gTeleportArrivalTimer.getElapsedTimeF32() >= (F32)gSavedSettings.getU32("SpeedRezInterval")) { gTeleportArrivalTimer.reset(); F32 current = gSavedSettings.getF32("RenderFarClip"); if (gSavedDrawDistance > current) { current *= 2.0; if (current > gSavedDrawDistance) { current = gSavedDrawDistance; } gSavedSettings.setF32("RenderFarClip", current); } if (current >= gSavedDrawDistance) { gSavedDrawDistance = 0.0f; gSavedSettings.setF32("SavedRenderFarClip", 0.0f); } } } ////////////////////////// // // Prepare for the next frame // ///////////////////////////// // // Update the camera // // LLAppViewer::instance()->pingMainloopTimeout("Display:Camera"); LLViewerCamera::getInstance()->setZoomParameters(zoom_factor, subfield); LLViewerCamera::getInstance()->setNear(MIN_NEAR_PLANE); ////////////////////////// // // clear the next buffer // (must follow dynamic texture writing since that uses the frame buffer) // if (gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Disconnected"); render_ui(); } ////////////////////////// // // Set rendering options // // LLAppViewer::instance()->pingMainloopTimeout("Display:RenderSetup"); stop_glerror(); /////////////////////////////////////// // // Slam lighting parameters back to our defaults. // Note that these are not the same as GL defaults... stop_glerror(); gGL.setAmbientLightColor(LLColor4::white); stop_glerror(); ///////////////////////////////////// // // Render // // Actually push all of our triangles to the screen. // // do render-to-texture stuff here if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_DYNAMIC_TEXTURES)) { LLAppViewer::instance()->pingMainloopTimeout("Display:DynamicTextures"); LLFastTimer t(FTM_UPDATE_TEXTURES); if (LLViewerDynamicTexture::updateAllInstances()) { gGL.setColorMask(true, true); glClear(GL_DEPTH_BUFFER_BIT); } } gViewerWindow->setup3DViewport(); gPipeline.resetFrameStats(); // Reset per-frame statistics. if (!gDisconnected) { LLAppViewer::instance()->pingMainloopTimeout("Display:Update"); if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD)) { //don't draw hud objects in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD); } if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES)) { //don't draw hud particles in this frame gPipeline.toggleRenderType(LLPipeline::RENDER_TYPE_HUD_PARTICLES); } //upkeep gl name pools LLGLNamePool::upkeepPools(); stop_glerror(); display_update_camera(tiling); stop_glerror(); // *TODO: merge these two methods LLHUDManager::getInstance()->updateEffects(); LLHUDObject::updateAll(); stop_glerror(); if(!tiling) { gFrameStats.start(LLFrameStats::UPDATE_GEOM); const F32 max_geom_update_time = 0.005f*10.f*gFrameIntervalSeconds; // 50 ms/second update time gPipeline.createObjects(max_geom_update_time); gPipeline.processPartitionQ(); gPipeline.updateGeom(max_geom_update_time); stop_glerror(); gPipeline.updateGL(); stop_glerror(); } gFrameStats.start(LLFrameStats::UPDATE_CULL); S32 water_clip = 0; if ((LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_ENVIRONMENT) > 1) && (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_WATER) || gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_VOIDWATER))) { if (LLViewerCamera::getInstance()->cameraUnderWater()) { water_clip = -1; } else { water_clip = 1; } } LLAppViewer::instance()->pingMainloopTimeout("Display:Cull"); //Increment drawable frame counter LLDrawable::incrementVisible(); LLSpatialGroup::sNoDelete = TRUE; LLTexUnit::sWhiteTexture = LLViewerFetchedTexture::sWhiteImagep->getTexName(); /*if (LLPipeline::sUseOcclusion && LLPipeline::sRenderDeferred) { //force occlusion on for all render types if doing deferred render LLPipeline::sUseOcclusion = 3; }*/ S32 occlusion = LLPipeline::sUseOcclusion; if (gDepthDirty) { //depth buffer is invalid, don't overwrite occlusion state LLPipeline::sUseOcclusion = llmin(occlusion, 1); } gDepthDirty = FALSE; LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); static LLCullResult result; LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; gPipeline.updateCull(*LLViewerCamera::getInstance(), result, water_clip); stop_glerror(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); BOOL to_texture = gPipeline.canUseVertexShaders() && LLPipeline::sRenderGlow; LLAppViewer::instance()->pingMainloopTimeout("Display:Swap"); { if (gResizeScreenTexture) { gResizeScreenTexture = FALSE; gPipeline.resizeScreenTexture(); } gGL.setColorMask(true, true); glClearColor(0,0,0,0); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); if (!for_snapshot || LLPipeline::sRenderDeferred) { if (gFrameCount > 1) { //for some reason, ATI 4800 series will error out if you //try to generate a shadow before the first frame is through gPipeline.generateSunShadow(*LLViewerCamera::getInstance()); } LLVertexBuffer::unbind(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); const LLMatrix4a saved_proj = glh_get_current_projection(); const LLMatrix4a saved_mod = glh_get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateFreezeCounter() ; if(!LLPipeline::sMemAllocationThrottled) { LLVOAvatar::updateImpostors(); } glh_set_current_projection(saved_proj); glh_set_current_modelview(saved_mod); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(saved_proj); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(saved_mod); gViewerWindow->setup3DViewport(); LLGLState::checkStates(); LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); } glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } LLGLState::checkStates(); LLGLState::checkClientArrays(); //if (!for_snapshot) { LLAppViewer::instance()->pingMainloopTimeout("Display:Imagery"); gPipeline.generateWaterReflection(*LLViewerCamera::getInstance()); gPipeline.renderPhysicsDisplay(); } LLGLState::checkStates(); LLGLState::checkClientArrays(); ////////////////////////////////////// // // Update images, using the image stats generated during object update/culling // // Can put objects onto the retextured list. // // Doing this here gives hardware occlusion queries extra time to complete LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages"); LLError::LLCallStacks::clear() ; llpushcallstacks ; gFrameStats.start(LLFrameStats::IMAGE_UPDATE); { LLFastTimer t(FTM_IMAGE_UPDATE); { LLFastTimer t(FTM_IMAGE_UPDATE_CLASS); LLViewerTexture::updateClass(LLViewerCamera::getInstance()->getVelocityStat()->getMean(), LLViewerCamera::getInstance()->getAngularVelocityStat()->getMean()); } { LLFastTimer t(FTM_IMAGE_UPDATE_BUMP); gBumpImageList.updateImages(); // must be called before gTextureList version so that it's textures are thrown out first. } { LLFastTimer t(FTM_IMAGE_UPDATE_LIST); F32 max_image_decode_time = 0.050f*gFrameIntervalSeconds; // 50 ms/second decode time max_image_decode_time = llclamp(max_image_decode_time, 0.002f, 0.005f ); // min 2ms/frame, max 5ms/frame) gTextureList.updateImages(max_image_decode_time); } /*{ LLFastTimer t(FTM_IMAGE_UPDATE_DELETE); //remove dead textures from GL LLImageGL::deleteDeadTextures(); stop_glerror(); }*/ } llpushcallstacks ; LLGLState::checkStates(); LLGLState::checkClientArrays(); /////////////////////////////////// // // StateSort // // Responsible for taking visible objects, and adding them to the appropriate draw orders. // In the case of alpha objects, z-sorts them first. // Also creates special lists for outlines and selected face rendering. // LLAppViewer::instance()->pingMainloopTimeout("Display:StateSort"); { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; gFrameStats.start(LLFrameStats::STATE_SORT); gPipeline.stateSort(*LLViewerCamera::getInstance(), result); stop_glerror(); if (rebuild) { ////////////////////////////////////// // // rebuildPools // // gFrameStats.start(LLFrameStats::REBUILD); gPipeline.rebuildPools(); stop_glerror(); } } LLGLState::checkStates(); LLGLState::checkClientArrays(); LLPipeline::sUseOcclusion = occlusion; { LLAppViewer::instance()->pingMainloopTimeout("Display:Sky"); LLFastTimer t(FTM_UPDATE_SKY); gSky.updateSky(); } // if(gUseWireframe) // [RLVa:KB] - Checked: 2010-09-28 (RLVa-1.1.3b) | Modified: RLVa-1.1.3b if ( (gUseWireframe) && ((!rlv_handler_t::isEnabled()) || (!gRlvAttachmentLocks.hasLockedHUD())) ) // [/RLVa:KB] { glClearColor(0.5f, 0.5f, 0.5f, 0.f); glClear(GL_COLOR_BUFFER_BIT); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderStart"); //// render frontmost floater opaque for occlusion culling purposes //LLFloater* frontmost_floaterp = gFloaterView->getFrontmost(); //// assumes frontmost floater with focus is opaque //if (frontmost_floaterp && gFocusMgr.childHasKeyboardFocus(frontmost_floaterp)) //{ // gGL.matrixMode(LLRender::MM_MODELVIEW); // gGL.pushMatrix(); // { // gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE); // gGL.loadIdentity(); // LLRect floater_rect = frontmost_floaterp->calcScreenRect(); // // deflate by one pixel so rounding errors don't occlude outside of floater extents // floater_rect.stretch(-1); // LLRectf floater_3d_rect((F32)floater_rect.mLeft / (F32)gViewerWindow->getWindowWidthScaled(), // (F32)floater_rect.mTop / (F32)gViewerWindow->getWindowHeightScaled(), // (F32)floater_rect.mRight / (F32)gViewerWindow->getWindowWidthScaled(), // (F32)floater_rect.mBottom / (F32)gViewerWindow->getWindowHeightScaled()); // floater_3d_rect.translate(-0.5f, -0.5f); // gGL.translatef(0.f, 0.f, -LLViewerCamera::getInstance()->getNear()); // gGL.scalef(LLViewerCamera::getInstance()->getNear() * LLViewerCamera::getInstance()->getAspect() / sinf(LLViewerCamera::getInstance()->getView()), LLViewerCamera::getInstance()->getNear() / sinf(LLViewerCamera::getInstance()->getView()), 1.f); // gGL.color4fv(LLColor4::white.mV); // gGL.begin(LLVertexBuffer::QUADS); // { // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mBottom, 0.f); // gGL.vertex3f(floater_3d_rect.mLeft, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mTop, 0.f); // gGL.vertex3f(floater_3d_rect.mRight, floater_3d_rect.mBottom, 0.f); // } // gGL.end(); // glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); // } // gGL.popMatrix(); //} LLPipeline::sUnderWaterRender = LLViewerCamera::getInstance()->cameraUnderWater() ? TRUE : FALSE; LLGLState::checkStates(); LLGLState::checkClientArrays(); stop_glerror(); if (to_texture) { gGL.setColorMask(true, true); if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.bindTarget(); glClearColor(1,0,1,1); gPipeline.mDeferredScreen.clear(); } else { gPipeline.mScreen.bindTarget(); if (LLPipeline::sUnderWaterRender && !gPipeline.canUseWindLightShaders()) { const LLColor4 &col = LLDrawPoolWater::sWaterFogColor; glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f); } gPipeline.mScreen.clear(); } gGL.setColorMask(true, false); } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderGeom"); if (!(LLAppViewer::instance()->logoutRequestSent() && LLAppViewer::instance()->hasSavedFinalSnapshot()) && !gRestoreGL) { LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD; static LLCachedControl<bool> render_ui_occlusion("RenderUIOcclusion", false); if(render_ui_occlusion && LLGLSLShader::sNoFixedFunction) { LLFloater* floaterp = gFloaterView->getFrontmost(); if(floaterp && floaterp->getVisible() && floaterp->isBackgroundVisible() && floaterp->isBackgroundOpaque()) { LLGLDepthTest depth(GL_TRUE, GL_TRUE); gGL.setColorMask(false, false); gOcclusionProgram.bind(); LLRect rect = floaterp->calcScreenRect(); rect.stretch(-1); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.pushMatrix(); gGL.loadIdentity(); gGL.ortho(0.0f, gViewerWindow->getWindowWidth(), 0.0f, gViewerWindow->getWindowHeight(), 0.f, 1.0f); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); gGL.color4fv( LLColor4::white.mV ); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.begin( LLRender::QUADS ); gGL.vertex3f(rect.mLeft, rect.mTop,0.f); gGL.vertex3f(rect.mLeft, rect.mBottom,0.f); gGL.vertex3f(rect.mRight, rect.mBottom,0.f); gGL.vertex3f(rect.mRight, rect.mTop,0.f); gGL.end(); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.popMatrix(); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); gOcclusionProgram.unbind(); } } static LLCachedControl<bool> render_depth_pre_pass("RenderDepthPrePass", false); if (render_depth_pre_pass && LLGLSLShader::sNoFixedFunction) { LLGLDepthTest depth(GL_TRUE, GL_TRUE); LLGLEnable cull_face(GL_CULL_FACE); gGL.setColorMask(false, false); U32 types[] = { LLRenderPass::PASS_SIMPLE, LLRenderPass::PASS_FULLBRIGHT, LLRenderPass::PASS_SHINY }; U32 num_types = LL_ARRAY_SIZE(types); gOcclusionProgram.bind(); for (U32 i = 0; i < num_types; i++) { gPipeline.renderObjects(types[i], LLVertexBuffer::MAP_VERTEX, FALSE); } gOcclusionProgram.unbind(); } gGL.setColorMask(true, false); if (LLPipeline::sRenderDeferred) { gPipeline.renderGeomDeferred(*LLViewerCamera::getInstance()); } else { gPipeline.renderGeom(*LLViewerCamera::getInstance(), TRUE); } gGL.setColorMask(true, true); //store this frame's modelview matrix for use //when rendering next frame's occlusion queries gGLPreviousModelView = gGLLastModelView; gGLLastModelView = gGLModelView; gGLLastProjection = gGLProjection; stop_glerror(); } //Reversed this. disabling a texunit sets its index as current.. randomly breaking LLRender::matrixMode(U32 mode). Make sure unit0 is the 'current' unit. for (S32 i = gGLManager.mNumTextureImageUnits-1; i >= 0; --i) { //dummy cleanup of any currently bound textures if (gGL.getTexUnit((U32)i)->getCurrType() != LLTexUnit::TT_NONE) { gGL.getTexUnit((U32)i)->unbind(gGL.getTexUnit((U32)i)->getCurrType()); gGL.getTexUnit((U32)i)->disable(); } } LLAppViewer::instance()->pingMainloopTimeout("Display:RenderFlush"); if (to_texture) { if (LLPipeline::sRenderDeferred) { gPipeline.mDeferredScreen.flush(); if(gPipeline.mDeferredScreen.getFBO()) { LLRenderTarget::copyContentsToFramebuffer(gPipeline.mDeferredScreen, 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), 0, 0, gPipeline.mDeferredScreen.getWidth(), gPipeline.mDeferredScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); } } else { gPipeline.mScreen.flush(); if(gPipeline.mScreen.getFBO()) { LLRenderTarget::copyContentsToFramebuffer(gPipeline.mScreen, 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), 0, 0, gPipeline.mScreen.getWidth(), gPipeline.mScreen.getHeight(), GL_DEPTH_BUFFER_BIT, GL_NEAREST); } } } //gGL.flush(); if (LLPipeline::sRenderDeferred) { gPipeline.renderDeferredLighting(); } LLPipeline::sUnderWaterRender = FALSE; LLAppViewer::instance()->pingMainloopTimeout("Display:RenderUI"); if (!for_snapshot || LLPipeline::sRenderDeferred) { LLFastTimer t(FTM_RENDER_UI); gFrameStats.start(LLFrameStats::RENDER_UI); render_ui(); } LLSpatialGroup::sNoDelete = FALSE; gPipeline.clearReferences(); gPipeline.rebuildGroups(); } LLAppViewer::instance()->pingMainloopTimeout("Display:FrameStats"); gFrameStats.start(LLFrameStats::MISC_END); stop_glerror(); if (LLPipeline::sRenderFrameTest) { send_agent_resume(); LLPipeline::sRenderFrameTest = FALSE; } display_stats(); LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); gShiftFrame = false; }
void veh_interact::exec (game *gm, vehicle *v, int x, int y) { g = gm; veh = v; ex = x; ey = y; // x1 x2 // y1 ----+------+-- // | | // y2 ----+------+ // | // | winw1 = 12; winw2 = 35; winh1 = 3; winh2 = 12; winw12 = winw1 + winw2 + 1; winw3 = 80 - winw1 - winw2 - 2; winh3 = 25 - winh1 - winh2 - 2; winh23 = winh2 + winh3 + 1; winx1 = winw1; winx2 = winw1 + winw2 + 1; winy1 = winh1; winy2 = winh1 + winh2 + 1; page_size = winh23; // h w y x w_grid = newwin(25, 80, 0, 0); w_mode = newwin(1, 80, 0, 0); w_msg = newwin(winh1 - 1, 80, 1, 0); w_disp = newwin(winh2, winw1, winy1 + 1, 0); w_parts = newwin(winh2, winw2, winy1 + 1, winx1 + 1); w_stats = newwin(winh3, winw12, winy2 + 1, 0); w_list = newwin(winh23, winw3, winy1 + 1, winx2 + 1); for (int i = 0; i < 25; i++) { mvwputch(w_grid, i, winx2, c_ltgray, i == winy1 || i == winy2? LINE_XOXX : LINE_XOXO); if (i >= winy1 && i < winy2) mvwputch(w_grid, i, winx1, c_ltgray, LINE_XOXO); } for (int i = 0; i < 80; i++) { mvwputch(w_grid, winy1, i, c_ltgray, i == winx1? LINE_OXXX : (i == winx2? LINE_OXXX : LINE_OXOX)); if (i < winx2) mvwputch(w_grid, winy2, i, c_ltgray, i == winx1? LINE_XXOX : LINE_OXOX); } wrefresh(w_grid); crafting_inv = gm->crafting_inventory(); int charges = ((it_tool *) g->itypes["welder"])->charges_per_use; has_wrench = crafting_inv.has_amount("wrench", 1) || crafting_inv.has_amount("toolset", 1); has_hacksaw = crafting_inv.has_amount("hacksaw", 1) || crafting_inv.has_amount("toolset", 1); has_welder = (crafting_inv.has_amount("welder", 1) && crafting_inv.has_charges("welder", charges)) || (crafting_inv.has_amount("toolset", 1) && crafting_inv.has_charges("toolset", charges/5)); display_stats (); display_veh (); move_cursor (0, 0); bool finish = false; while (!finish) { char ch = input(); // See keypress.h int dx, dy; get_direction (gm, dx, dy, ch); if (ch == KEY_ESCAPE) finish = true; else if (dx != -2 && (dx || dy) && cx + dx >= -6 && cx + dx < 6 && cy + dy >= -6 && cy + dy < 6) move_cursor(dx, dy); else { int mval = cant_do(ch); display_mode (ch); switch (ch) { case 'i': do_install(mval); break; case 'r': do_repair(mval); break; case 'f': do_refill(mval); break; case 'o': do_remove(mval); break; case 'e': do_rename(mval); break; default:; } if (sel_cmd != ' ') finish = true; display_mode (' '); } } werase(w_grid); werase(w_mode); werase(w_msg); werase(w_disp); werase(w_parts); werase(w_stats); werase(w_list); delwin(w_grid); delwin(w_mode); delwin(w_msg); delwin(w_disp); delwin(w_parts); delwin(w_stats); delwin(w_list); erase(); }