void draw(t_env *e) { t_vect2i p; t_vect2i s; s = set_vect2i((COLS - 1) / 4, (LINES - 1) / 4 - 1); draw_ui(ft_itoa(e->score), s); p.y = -1; check_end(e->score, e->map); while (++p.y <= (s.y * 4) + 1) { p.x = -1; while (++p.x <= (s.x * 4)) { if (p.x < (s.x * 4) && (p.y % (s.y) == 0 || p.y == (s.y * 4))) { while (p.x < (s.x * 4)) mvprintw(p.y + 3, p.x, ((p.x++) % (s.x) == 0) ? "+" : "-"); mvprintw(p.y + 3, p.x, "+"); } else if (p.y < (s.y * 4) && (p.x % (s.x) == 0 || p.x == (s.x * 4))) mvprintw(p.y + 3, p.x, "|"); } } draw_numbers(e->map, s); }
int gfx_engine() { test_function();// used for debug commands and stuff. draw_ui(); // draws the ui and compress all buffers down to the screen_buffer, so only one draw to the screen is made. draw_map();// draws the individual tiles that correspond to the tile numbers in the map array. blit (screen_buffer, screen, 0,0,0,0,1024,768); rectfill (screen_buffer, 0,0,1024,768,makecol(0,0,0)); return 0; }
bool render_game() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mat4 t = ident; draw_maps(t); draw_player(); draw_actors(); draw_ui(); return true; }
int gere_expose(t_param *param) { mlx_put_image_to_window(param->window.p, param->window.id, param->image.img, 0, 0); draw_ui(param); if (param->click_menu == 1) { mlx_put_image_to_window(param->window.p, param->window.id, param->panel_control.img, 165, 10); draw_conf(param); } return (0); }
void draw_game(game *g) { int i; al_clear_to_color(BACKGROUND_COLOR); if(g->status == Pause || g->status == Win || g->status == Lose) draw_menu(g); else if(g->status == Config) draw_config(g); else if(g->status != Quit) { draw_ui(g); draw_ship(g); draw_shoots(g); draw_asteroids(g); } }
void message_time(char *message,int duration) { sprite_start_frame(); sprite_group_draw2(mech_group); sprite_group_draw(bomb_group); sprite_group_draw(bullet_group); sprite_group_draw(effects_group); sprite_group_draw(foreground_group); sprite_group_draw(ui_group); text_render(sprite_global.display, 0, big_font, sprite_global.display->w / 2, sprite_global.display->h / 2, ALIGN_CENTER, ALIGN_CENTER, message); draw_ui(); sprite_end_frame(); sprite_dirty_all(); sleep(duration); }
int main(int argc, char **argv) { Escen_Viewer *thiz; int width; int height; char *file; const char *engine; if (argc < 4) { help(); return 0; } if (argc > 4) { engine = argv[1]; width = strtol(argv[2], NULL, 10); height = strtol(argv[3], NULL, 10); file = argv[4]; } else { width = strtol(argv[1], NULL, 10); height = strtol(argv[2], NULL, 10); file = argv[3]; engine = "sdl"; } eon_init(); escen_init(); thiz = escen_viewer_new(engine, width, height, file); if (!thiz) return -1; draw_ui(thiz); eon_backend_run(thiz->backend); escen_viewer_free(thiz); escen_shutdown(); eon_shutdown(); return 0; }
void connect_frame(){ //usleep(100000); int i; /* collect frame time statistics */ static Uint32 lasttime = 0; Uint32 now = SDL_GetTicks(); frame_times[frame_time_i] = now - lasttime; frame_time_i = (frame_time_i + 1) & 31; lasttime = now; sprite_start_frame(); sprite_group_draw(ui_group_connect); draw_ui(); if (!sprite_end_frame()) { //printf("lag"); //fflush(stdout); } }
/* This draws things when we are in console (paused) mode */ void console_frame(void) { sprite_start_frame(); sprite_group_draw2(mech_group); sprite_group_draw(bullet_group); sprite_group_draw(bomb_group); sprite_group_draw(effects_group); sprite_group_draw(foreground_group); if (inGame){ sprite_group_draw(ui_group); }else{ sprite_group_draw(ui_group_connect); } winds_change(); draw_ui(); console_draw(); sprite_end_frame(); }
//TODO: ES2ify void App::render_content(double time_since_last_frame) { pointcloud_state state = pointcloud_get_state(); // Draw the content if we have SLAM or image tracking if (state == POINTCLOUD_TRACKING_SLAM_MAP || state == POINTCLOUD_TRACKING_IMAGES) { switch_to_camera(); // // Set light position // static const float light_position[4] = {1, 6, 0.5, 1.0f}; // glLightfv(GL_LIGHT0, GL_POSITION, light_position); // // glColor4f(1,0,0,1); // // glDisable(GL_TEXTURE_2D); // glEnable(GL_COLOR_MATERIAL); // glShadeModel(GL_FLAT); // // glEnableClientState(GL_VERTEX_ARRAY); // glEnableClientState(GL_NORMAL_ARRAY); // // glVertexPointer(3, GL_FLOAT, 0, (float *)cuboid_vertices); // glNormalPointer(GL_FLOAT, 0, (float *)cuboid_normals); // glDrawArrays(GL_TRIANGLE_STRIP, 0, 19); // // glDisableClientState(GL_NORMAL_ARRAY); // glDisableClientState(GL_VERTEX_ARRAY); // // glShadeModel(GL_SMOOTH); // glDisable(GL_COLOR_MATERIAL); // glColor4f(1, 1, 1, 1); } // Draw the UI on top of the content switch_to_ortho(); draw_ui(); }
void render_game(Game* G) { render_graphics(G->graphics); draw_ui(G->ui); }
/* Creates a new game frame */ void game_frame() { //usleep(100000); int i; /* collect frame time statistics */ static Uint32 lasttime = 0; Uint32 now = SDL_GetTicks(); frame_times[frame_time_i] = now - lasttime; frame_time_i = (frame_time_i + 1) & 31; lasttime = now; /* sprite_viewport_center_on(player_sprite[0]);*/ sprite_start_frame(); sprite_group_move(mech_group, sprite_global.dt); sprite_group_move(bullet_group, sprite_global.dt); sprite_group_move(bomb_group, sprite_global.dt); sprite_group_move(effects_group, sprite_global.dt); sprite_group_move(foreground_group, sprite_global.dt); sprite_group_animate(mech_group, sprite_global.dt); sprite_group_animate(bullet_group, sprite_global.dt); sprite_group_animate(bomb_group, sprite_global.dt); sprite_group_animate(effects_group, sprite_global.dt); sprite_group_animate(foreground_group, sprite_global.dt); mech_gravity(mech_group); /* has to be before bg_coll */ mech_gravity(bomb_group); /* has to be before bg_coll */ if(planeCollision){ sprite_group_coll(mech_group, mech_sprite_collide); } sprite_group_coll2(bullet_group, mech_group, 0); sprite_group_coll2(bomb_group, mech_group, 0); sprite_group_coll2(bomb_group, bullet_group, 0); sprite_group_coll2(bomb_group, bomb_group, 0); sprite_group_bg_coll(mech_group, mech_sprite_bg_collide); sprite_group_bg_coll(bullet_group, 0); sprite_group_bg_coll(bomb_group, 0); for (i = 0; i < playerCount; i++) { players[i].controller->update(players[i].controller); } sprite_group_update(mech_group); sprite_group_update(bullet_group); sprite_group_update(bomb_group); sprite_group_update(effects_group); sprite_group_update(foreground_group); sprite_group_update(ui_group); sprite_group_cleanup(bullet_group); sprite_group_cleanup(bomb_group); sprite_group_cleanup(mech_group); sprite_group_cleanup(effects_group); sprite_group_cleanup(foreground_group); sprite_group_cleanup(ui_group); /* Refresh sprite positions to reflect changes by collisions */ sprite_group_pos_update(mech_group); sprite_group_draw(effects_group); sprite_group_draw2(mech_group); sprite_group_draw(bullet_group); sprite_group_draw(bomb_group); sprite_group_draw(foreground_group); sprite_group_draw(ui_group); draw_ui(); if (!sprite_end_frame()) { //printf("lag"); //fflush(stdout); } scorekeeper(); }
void update_and_render(Memory *memory, GameState *game_state, FrameBuffer *frame_buffer, Keys *keys, Mouse *mouse, u64 time_us, u32 last_frame_dt, u32 fps , u32 argc, char *argv[]) { if (!game_state->init) { init_render_segments(memory, game_state, frame_buffer); init_game(memory, game_state, keys, time_us, argc, argv); load_maze(memory, game_state, argc, argv); reset_zoom(game_state); } update_inputs(keys, &game_state->inputs, time_us); if (game_state->inputs.maps[SAVE].active) { serialize_maze(&game_state->maze, &game_state->functions, game_state->filename); } if (game_state->inputs.maps[RELOAD].active) { strcpy(game_state->persistent_str, "Reload!"); load_maze(memory, game_state, argc, argv); } if (game_state->inputs.maps[RESET].active) { strcpy(game_state->persistent_str, "Reset!"); reset_zoom(game_state); } if (game_state->inputs.maps[RESTART].active) { strcpy(game_state->persistent_str, "Restart!"); delete_all_cars(&game_state->cars); reset_car_inputs(&game_state->ui); game_state->finish_sim_step_move = false; game_state->last_sim_tick = 0; game_state->sim_steps = 0; } if (game_state->inputs.maps[STEP_MODE_TOGGLE].active) { game_state->single_step = !game_state->single_step; log(L_GameLoop, "Changing stepping mode"); } // // UPDATE VIEW // update_pan_and_zoom(game_state, mouse); RenderBasis render_basis; render_basis.world_per_pixel = game_state->world_per_pixel; render_basis.scale = squared(game_state->zoom / 30.0f); render_basis.scale_focus = game_state->scale_focus; render_basis.origin = game_state->maze_pos * game_state->world_per_pixel; render_basis.clip_region = game_state->world_render_region * game_state->world_per_pixel; RenderBasis orthographic_basis; get_orthographic_basis(&orthographic_basis, game_state->screen_render_region); // // UPDATE WORLD // ui_consume_mouse_clicks(game_state, &orthographic_basis, &game_state->ui, mouse, time_us); if (game_state->inputs.maps[SIM_TICKS_INC].active) { game_state->sim_ticks_per_s += .5f; } if (game_state->inputs.maps[SIM_TICKS_DEC].active) { game_state->sim_ticks_per_s -= .5f; } game_state->sim_ticks_per_s = clamp(.5, game_state->sim_ticks_per_s, 20); update_cells_ui_state(game_state, &render_basis, mouse, time_us); b32 sim = sim_tick(game_state, time_us); if (sim && game_state->ui.car_inputs == 0 && !game_state->finish_sim_step_move) { perform_cells_sim_tick(memory, game_state, &(game_state->maze.tree), time_us); perform_cars_sim_tick(memory, game_state, time_us); } if (sim && game_state->ui.car_inputs == 0) { move_cars(game_state); game_state->finish_sim_step_move = false; ++game_state->sim_steps; } annimate_cars(game_state, last_frame_dt); step_particles(&(game_state->particles), time_us); update_ui(game_state, &orthographic_basis, &game_state->ui, mouse, &game_state->inputs, time_us); // // RENDER // // Add render operations to queue game_state->render_operations.next_free = 0; add_fast_box_to_render_list(&game_state->render_operations, &orthographic_basis, (Rectangle) { (V2) {0,0},size(game_state->screen_render_region) }, (PixelColor) { 255, 255, 255 }); draw_cells(game_state, &game_state->render_operations, &render_basis, &(game_state->maze.tree), time_us); draw_cars(game_state, &game_state->render_operations, &render_basis, &(game_state->cars), time_us); // render_particles(&(game_state->particles), &game_state->render_operations, &render_basis); r32 text_scale = 0.3; draw_string(&game_state->render_operations, &orthographic_basis, &game_state->bitmaps.font, size(game_state->screen_render_region) - CHAR_SIZE*text_scale*(V2) { strlen(game_state->persistent_str), 1 }, game_state->persistent_str, text_scale, (V4) { 1, 0, 0, 0 }); draw_ui(&game_state->render_operations, &orthographic_basis, &render_basis, &game_state->bitmaps.font, &game_state->cell_bitmaps, &game_state->ui, time_us); char str[4]; fmted_str(str, 4, "%d", fps); draw_string(&game_state->render_operations, &orthographic_basis, &game_state->bitmaps.font, (V2) { 0, 0 }, str, 0.3, (V4) { 1, 0, 0, 0 }); // Add render segments to render queue V2 ns = game_state->render_segs.n_segments; V2 s; for (s.y = 0; s.y < ns.y; ++s.y) { for (s.x = 0; s.x < ns.x; ++s.x) { RenderQueueData render_data; Rectangle *segment = game_state->render_segs.segments + (u32)s.y + (u32)ns.y*(u32)s.x; render_data.clip_region = *segment; render_data.frame_buffer = frame_buffer; render_data.render_operations = &game_state->render_operations; #ifdef THREADED_RENDERING pthread_mutex_lock(&game_state->render_queue.mut); while (game_state->render_queue.full) { log(L_RenderQueue, "producer: queue FULL."); pthread_cond_wait(&game_state->render_queue.not_full, &game_state->render_queue.mut); } log(L_RenderQueue, "producer: Adding."); queue_add(&game_state->render_queue, render_data); pthread_mutex_unlock(&game_state->render_queue.mut); pthread_cond_signal(&game_state->render_queue.not_empty); #else consume_render_operations(render_data.frame_buffer, render_data.render_operations, render_data.clip_region); #endif } } // TODO: Wait for frame rendering to finish // TODO: Get rid of this game_state->last_render_basis = render_basis; }
int main(int argc, char **argv) { world_t world; game_t game; double last_time = 0; double current_time = 0; float deltatime = 0; float sleep_time; if (config_from_file("anko.cfg", 1) == 2) return EXIT_FAILURE; if (config_from_args(argc, argv)) return EXIT_FAILURE; if (!init()) goto err_init; if (!new_game(&game, config.board_width, config.board_height, &config.gen_params, config.sim_speed * 1000)) goto err_game; if (!create_world(&world, &game)) goto err_world; if ((current_ui = init_ui_game(&world)) == NULL) goto err_ui; world_set_active_player(&world, add_player(&game, TEAM_BURNER)); events_link_frame(¤t_ui); // link window event to game ui frame glClearColor(0, 0, 0, 1); last_time = 0; while(!glfwWindowShouldClose(window)) { current_time = glfwGetTime(); deltatime = current_time - last_time; update_speed(deltatime); glfwPollEvents(); // Update update_ui(current_ui, deltatime); update_world(&world); if (update_game(&game, deltatime * 1000)) refresh_world(&world); if(should_quit) glfwSetWindowShouldClose(window, GL_TRUE); // Rendering glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); draw_ui(current_ui); font_swap_buffers(); glfwSwapBuffers(window); // Update speed and sleep if necessary last_time = current_time; sleep_time = (current_time + MAX_MSPF - glfwGetTime()) * 1000 * 1000; if(sleep_time > 0) usleep(sleep_time); } destroy_ui(current_ui); game_over(&game); end_of_the_world(&world); // Tin tin tin terminate(); return EXIT_SUCCESS; err_ui: end_of_the_world(&world); err_world: game_over(&game); err_game: terminate(); err_init: return EXIT_FAILURE; }
int main(int argc, const char* argv[]) { argc--; argv++; srand (time(NULL)); db_ranking db; int change_rate = 10; if ( argc > 1 ){ sscanf(argv[1], "%d", &change_rate); } diagnosis_phase_detector::phase phases[4] = { diagnosis_phase_detector::diagnosis_plain, diagnosis_phase_detector::diagnosis_green, diagnosis_phase_detector::diagnosis_hinselmann, diagnosis_phase_detector::diagnosis_schiller }; map<diagnosis_phase_detector::phase, string> names; names[diagnosis_phase_detector::diagnosis_plain] = "plain"; names[diagnosis_phase_detector::diagnosis_green] = "green"; names[diagnosis_phase_detector::diagnosis_hinselmann] = "hinselmann"; names[diagnosis_phase_detector::diagnosis_schiller] = "schiller"; int current_phase_index = 0; diagnosis_phase_detector::phase cphase = phases[current_phase_index]; // Parse the videos specified in the input file ifstream fin(argv[0]); string next_seq; //int counter = 5; int vindex = 0; while ( getline(fin, next_seq) != 0 /*&& counter-- > 0*/ ){ cout << next_seq << endl; // Filaname filenames.push_back(next_seq); // Index v_index.push_back(db.get_video_index(next_seq)); // Sequence of frames map<diagnosis_phase_detector::phase, vector<int> > next_frames; get_sequence(next_seq.c_str(), next_frames); frames.push_back(next_frames); // Frame generator map<diagnosis_phase_detector::phase, layer_generator> next_generator; get_generator(next_frames, next_generator); generators.push_back(next_generator); // Annotated instance anonadado::instance* next_instance = new anonadado::instance(); next_instance->read(next_seq.c_str()); instances.push_back(next_instance); cout << "Video " << vindex++ << " done." << endl; } fin.close(); bool has = true; bool exit = false; bool go_to_next_phase = false; while ( !exit && has ){ int remaining = change_rate; go_to_next_phase = false; cout << "\n\n\n NEEEEXT!\n\n\n"; cout << current_phase_index << " " << cphase << endl; cout << endl << endl; for ( int level = 0; has && !exit && !go_to_next_phase; level++ ) { cout << "LEVEL " << level << endl; //boost::this_thread::sleep( boost::posix_time::seconds(1) ); vector< pair<int, pair< pair<int, int>, pair<int, int> > > > pairs; // Generate pairs <(video, frame), (video, frame)> for this level for ( size_t va = 0; va < instances.size(); va++ ){ vector<int> framesl_a; generators[va][cphase].get_next(framesl_a, level); for ( size_t fa = 0; fa < framesl_a.size(); fa++){ for ( size_t vb = 0; vb < va; vb++ ){ vector<int> framesl_b; generators[vb][cphase].get_next(framesl_b, level); for ( size_t fb = 0; fb < framesl_b.size(); fb++ ){ if ( va == vb && framesl_a[fa] == framesl_b[fb] ){ continue; } int priority = min(db.num_annotated_frames(v_index[va]), db.num_annotated_frames(v_index[vb])); pairs.push_back( make_pair(priority, make_pair(make_pair(va, framesl_a[fa]), make_pair(vb, framesl_b[fb]) ) ) ); } } } } if ( pairs.size() == 0 ){ has = false; break; } else { has = true; } // Randomly sort these pairs vector<int> change_priorities; sort(pairs.begin(), pairs.end()); change_priorities.push_back(0); for (size_t i = 1; i < pairs.size(); i++){ if ( pairs[i].first != pairs[i - 1].first ){ change_priorities.push_back(i); } } change_priorities.push_back(pairs.size()); for (size_t i = 0; i + 1 < change_priorities.size(); i++){ random_shuffle(pairs.begin() + change_priorities[i], pairs.begin() + change_priorities[i + 1]); } // Eval these pairs for ( size_t i = 0; i < pairs.size() && !go_to_next_phase; i++ ){ int va = pairs[i].second.first.first; int fa = pairs[i].second.first.second; int vb = pairs[i].second.second.first; int fb = pairs[i].second.second.second; cout << filenames[va] << " " << filenames[vb] << endl; cout << "(" << va << ":" << fa << ") " << "(" << vb << ":" << fb << ") " << endl; if ( db.exists(cphase, v_index[va], frames[va][cphase][fa], v_index[vb], frames[vb][cphase][fb]) ) { continue; } better = -1; bool save = true; while ( true ){ Mat a, b, dst; instances[va]->get_frame(frames[va][cphase][fa], a); instances[vb]->get_frame(frames[vb][cphase][fb], b); draw_ui(a, b, dst); imshow(names[cphase], dst); int key = waitKey(0) % 0x100; if ( key == 81 ){ better = 1; } else if ( key == 83 ){ better = 0; } else if ( key == 32 ){ break; } else if ( key == 27 ){ exit = true; has = false; break; } else if ( key == 115 ){ // Skip save = false; break; } else { better = -1; } } if ( exit ){ break; } // Save the annotation if ( save ){ db.insert_annotation(cphase, v_index[va], frames[va][cphase][fa], v_index[vb], frames[vb][cphase][fb], better); } cout << "remaining " << remaining << endl; remaining--; if ( remaining <= 0 ){ go_to_next_phase = true; break; } } } cout << "go to next\n"; cvDestroyWindow(names[cphase].c_str()); current_phase_index = (current_phase_index + 1) % 4; cphase = phases[current_phase_index]; } cout << "Bye!\n"; return 0; }