static void initialize(void) { int attr; attr = doublebuffer ? RGBA_DB_attributes : RGBA_SB_attributes; glutInitDisplayMode(attr); glutInitWindowSize(300, 240); glutCreateWindow("Ideas"); if (multisample) glEnable(GL_POLYGON_SMOOTH); init_lights(); init_materials(); build_table(); view_from_spline = calc_spline_params(view_from_ctl, TIME); view_to_spline = calc_spline_params(view_to_ctl, TIME); light_pos_spline = calc_spline_params(light_pos_ctl, TIME); logo_pos_spline = calc_spline_params(logo_pos_ctl, TIME); logo_rot_spline = calc_spline_params(logo_rot_ctl, TIME); glutReshapeFunc(resize_window); glutDisplayFunc(display); glutMouseFunc(mouse); glutKeyboardFunc(keyboard); glutVisibilityFunc(vis); glMatrixMode(GL_MODELVIEW); }
void onInit() { sys::info << "app::COGLDev06NormalMapApp::onInit()" << sys::endl; pCamera = new app::CCamera(60.0f, mConfig.mRatio, 0.1f, 100.0f); pCamera->translateLocal(math::vec3(0.0f, -2.0f, -5.0f)); pShadowFBO = new ogl::CShadowFramebuffer(mConfig.mWidth, mConfig.mHeight); init_programs(); init_lights(); init_textures(); init_objects(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepthf(1.0f); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glCullFace(GL_BACK); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); }
// main int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowSize(800, 800); glutInitWindowPosition(300, 300); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); glutCreateWindow("Cottages"); init_menu(); init_objects(); init_lights(); glutReshapeFunc(reshape); glutDisplayFunc(draw); glutIdleFunc(idle); glutSpecialFunc(pressSpecialKeys); glutSpecialUpFunc(releaseSpecialKeys); glutKeyboardUpFunc(releaseKeys); glutMotionFunc(motion); glutMouseFunc(mouse); glutMainLoop(); delete cottage; delete diamond; delete lamp; delete ground; return 0; }
plt_director * plt_director_open(void) { plt_director * director = calloc(1, sizeof(plt_director)); director->camera.angle_x = 0; director->camera.angle_y = 0; director->camera.distance = 5; glShadeModel(GL_SMOOTH); glPixelStorei(GL_UNPACK_ALIGNMENT, 4); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glEnable(GL_BLEND); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); glClearColor(0, 0, 0, 0); glClearStencil(0); glClearDepth(1.0f); glDepthFunc(GL_LEQUAL); init_lights(); set_camera(0, 0, 10, 0, 0, 0); return director; }
void onInit() { sys::info << "app::COGLDev42PCFShadowMapApp::onInit() " << sys::endl; init_cameras(); init_programs(); init_lights(); init_objects(); init_renderers(); }
void onInit() { sys::info << "app::COGLDev10TessellationApp::onInit() " << sys::endl; init_cameras(); init_programs(); init_lights(); init_objects(); init_renderers(); glExitIfError(); }
int main( int argc, char **argv ) { if ( use_gui ) { printf("init_sdl()\n"); if ( init_sdl() ) return 1; printf("init_gl()\n"); init_gl(); } printf("init_fft()\n"); if ( init_fft() ) return 1; if ( use_serial ) { printf("init_serial()\n"); if ( init_serial() ) use_serial = FALSE; } init_lights(); init_table(); while ( !done ) { get_samples_do_fft(); detect_beats(); assign_lights(); assign_cells(); if ( use_gui ) { if (handle_sdl_events()) return 1; draw_all(); } if ( use_serial ) send_serial(); usleep(5000); } return 0; }
void init_scene(t_rt *rt, char *scene) { if (rt) { rt->objs = NULL; rt->lights = NULL; if (!(rt->camera)) init_camera(&(rt->camera), *(rt->screen), rt->space); load_scene(rt, scene); if (!(rt->lights)) init_lights(&(rt->lights)); if (!(rt->objs)) init_objs(&(rt->objs)); if (scene) free(scene); } }
/* * Ubiquitous main function, argv and all * */ int main(int argc, char* argv[]) { int bez[] = { GLUT_KEY_F1, GLUT_KEY_F2, GLUT_KEY_F3, GLUT_KEY_F4, GLUT_KEY_F5, GLUT_KEY_F6, GLUT_KEY_F7, GLUT_KEY_F8, GLUT_KEY_F9, 0, }; glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA|GLUT_DEPTH|GLUT_DOUBLE); glutCreateWindow("University of Missouri Campus"); glutDisplayFunc(display); glutReshapeFunc(reshape); glutMouseFunc(mouse_click); glutMotionFunc(mouse_drag); // real-time muliple key-presses initKeyboard(50); keyboardCallbackv("asdfhjklionm", move_camera); keyboardCallback(27, closeWin); keyboardSpecialCallback(GLUT_KEY_F12, fillMode); keyboardSpecialCallback(GLUT_KEY_F11, free_camera); keyboardSpecialCallback(GLUT_KEY_F10, circle_camera); keyboardSpecialCallbackv(bez, bezier_camera); init_lights(); init_campus(); init_camera(); glutFullScreen(); glutMainLoop(); return 0; }
void GAMECONTROLLER::init_doors() { dbg_msg("door", "i inits nao!"); for(int doorno = 0; doorno < 16; doorno++) { if(doorno <10) { doors[doorno].team = -1; } else if(doorno >=10 && doorno < 13) { doors[doorno].team = 0; //red door } else { doors[doorno].team = 1; //blue door } if(!doors[doorno].valid) continue; doors[doorno].pos[0] = doors[doorno].tmpstart; for(int i = 0; i < doors[doorno].pos_count; i++) { //dbg_msg("door", "i has a door %f:%f", doors[doorno].pos[i].x, doors[doorno].pos[i].y); int dist = -1; for(int j = 0; j < doors[doorno].pos_count; j++) { if(doors[doorno].mark[j]) continue; if(dist < 0) dist = j; else { float olddist = distance(doors[doorno].tmppos[dist], doors[doorno].pos[i]); float newdist = distance(doors[doorno].tmppos[j], doors[doorno].pos[i]); if(newdist < olddist) dist = j; } } doors[doorno].pos[i+1] = doors[doorno].tmppos[dist]; doors[doorno].mark[dist] = true; } doors[doorno].pos_count += 2; doors[doorno].pos[doors[doorno].pos_count-1] = doors[doorno].tmpend; } dbg_msg("door","i s dun!"); init_lights(); for(int i = 0; i < 16; i++) set_door(i, true); }
void AD_Scene3D::init (void) { int k; init_materials(); init_lights(); init_camere(); init_objects(); for (k=0; k<num_materials+2; k++) { if (materials[k].trasparencytype==OFF) { materials[k].my_tria_list=(void **) new AD_Tria3DPtr[materials[k].my_num_tria]; materials[k].my_tria_list_copy=materials[k].my_tria_list; } } counter_for_resetting_vertex=0; zclear=-1; return; }
int main(int argc, char **argv){ /* initialize sdl */ if (SDL_Init(SDL_INIT_VIDEO) < 0){ perror("could not initialize sdl"); return 1; } SDL_ShowCursor(SDL_DISABLE); SDL_WM_SetCaption("simple raytracer demo", ""); SDL_Surface *screen = SDL_SetVideoMode(WIDTH, HEIGHT, BPP*8, SDL_HWSURFACE|SDL_DOUBLEBUF); if(!screen) { perror("could not set video mode"); SDL_Quit(); return 1; } /* initialize graphics state */ graphics_state state; state.screen = screen; if(init_model(&state) != 0) return -1; if(init_lights(&state) != 0) return -1; if(init_graphics(&state) != 0) return -1; if(init_worker_threads(&state) != 0) return -1; /* main loop */ int run = 1; float ema_nanos = 0, ema_nanos2 = 0, max_nanos = 0; long start_time; start_time = now(); while(run){ /* change the scene */ timestep(&state); /* render the scene */ if(draw_screen(&state)){ perror("render error"); return 1; } /* performance metrics */ state.frame++; long nanos = now()-start_time; ema_nanos = 0.9f*ema_nanos + 0.1*nanos; ema_nanos2 = 0.9f*ema_nanos2 + 0.1*nanos*nanos; if(nanos > max_nanos) max_nanos = nanos; if(state.frame % 10 == 0){ float stdev_nanos = sqrtf(ema_nanos2 - ema_nanos*ema_nanos); float fps = 1000000000 / ema_nanos; float fps_sigma = 1000000000 / (ema_nanos + stdev_nanos); float fps_worst = 1000000000 / max_nanos; printf("%.2f +/- %.2f (worst: %.2f) fps\n", fps, fps-fps_sigma, fps_worst); max_nanos = 0; } start_time = now(); int sleep_us = TARGET_US - nanos/1000; if(sleep_us > 0) usleep(sleep_us); /* check if we need to exit */ SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_QUIT || event.type == SDL_MOUSEBUTTONDOWN){ run = 0; break; } } } /* reset resolution to normal, exit */ SDL_Quit(); return 0; }
void init_stuff() { int i; int seed; chdir(DATA_DIR); #ifndef WINDOWS setlocale(LC_NUMERIC,"en_US"); #endif init_translatables(); //create_error_mutex(); init_globals(); init_crc_tables(); init_zip_archives(); cache_system_init(MAX_CACHE_SYSTEM); init_texture_cache(); init_vars(); read_config(); file_check_datadir(); #ifdef LOAD_XML //Well, the current version of the map editor doesn't support having a datadir - will add that later ;-) load_translatables(); #endif #ifdef LINUX #ifdef GTK2 init_filters(); #else file_selector = create_fileselection(); #endif #endif //LINUX init_gl(); window_resize(); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); // glDepthFunc(GL_LEQUAL); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glFrontFace(GL_CCW); glCullFace(GL_BACK); glEnable(GL_NORMALIZE); glClearColor( 0.0, 0.0, 0.0, 0.0 ); glClearStencil(0); seed = time (NULL); srand (seed); init_texture_cache(); init_particles (); init_e3d_cache(); init_2d_obj_cache(); for(i=0; i<256; i++) tile_list[i]=0; for (i = 0; i < MAX_LIGHTS; i++) lights_list[i] = NULL; new_map(256,256); load_all_tiles(); //lights setup build_global_light_table(); build_sun_pos_table(); reset_material(); init_lights(); //disable_local_lights(); //clear_error_log(); // Setup the new eye candy system #ifdef EYE_CANDY ec_init(); #endif //EYE_CANDY init_gl_extensions(); if(have_multitexture) #ifdef NEW_TEXTURES ground_detail_text = load_texture_cached("./textures/ground_detail.bmp", tt_mesh); #else /* NEW_TEXTURES */ ground_detail_text = load_texture_cache ("./textures/ground_detail.bmp",255); #endif /* NEW_TEXTURES */ //load the fonts texture init_fonts(); #ifdef NEW_TEXTURES icons_text=load_texture_cached("./textures/gamebuttons.bmp", tt_gui); buttons_text=load_texture_cached("./textures/buttons.bmp", tt_gui); #else /* NEW_TEXTURES */ icons_text=load_texture_cache("./textures/gamebuttons.bmp",0); buttons_text=load_texture_cache("./textures/buttons.bmp",0); #endif /* NEW_TEXTURES */ //get the application home dir have_multitexture=0;//debug only #ifndef LINUX GetCurrentDirectory(sizeof(exec_path),exec_path); #else exec_path[0]='.';exec_path[1]='/';exec_path[2]=0; #endif init_browser(); if(SDL_InitSubSystem(SDL_INIT_TIMER)<0) { char str[120]; snprintf(str, sizeof(str), "Couldn't initialize the timer: %s\n", SDL_GetError()); log_error(__FILE__, __LINE__, str); SDL_Quit(); exit(1); } SDL_SetTimer (1000/(18*4), my_timer); SDL_EnableUNICODE(1); //we might want to do this later. // creating windows display_browser(); toggle_window(browser_win); display_o3dow(); toggle_window(o3dow_win); display_replace_window(); toggle_window(replace_window_win); display_edit_window(); toggle_window(edit_window_win); create_particles_window (); }
void init_stuff() { int seed; Uint32 (*my_timer_pointer) (unsigned int) = my_timer; //TODO: process command line options chdir(datadir); //Initialize all strings init_translatables(); #ifdef WRITE_XML load_translatables();//Write to the current working directory - hopefully we'll have write rights here... #endif //read the config file read_config(); //Parse command line options read_command_line(); //OK, we have the video mode settings... setup_video_mode(full_screen,video_mode); //now you may set the video mode using the %<foo> in-game video_mode_set=1; //Good, we should be in the right working directory - load all translatables from their files load_translatables(); init_video(); resize_window(); init_gl_extensions(); #ifdef CAL3D create_cal3d_model(); init_cal3d_model(); #endif seed = time (NULL); srand (seed); cache_system_init(MAX_CACHE_SYSTEM); init_texture_cache(); init_md2_cache(); init_e3d_cache(); init_2d_obj_cache(); load_ignores(); load_filters(); load_e3d_list(); load_e2d_list(); load_part_list(); load_knowledge_list(); load_cursors(); build_cursors(); change_cursor(CURSOR_ARROW); build_glow_color_table(); init_actors_lists(); memset(tile_list, 0, sizeof(tile_list)); memset(lights_list, 0, sizeof(lights_list)); init_particles_list(); memset(actors_defs, 0, sizeof(actors_defs)); init_actor_defs(); load_map_tiles(); //lights setup build_global_light_table(); build_sun_pos_table(); reset_material(); init_lights(); disable_local_lights(); init_colors(); clear_error_log(); clear_conn_log(); clear_thunders(); build_rain_table(); read_bin_cfg(); build_levels_table();//for some HUD stuff init_scale_array(); if(!no_sound)init_sound(); //initialize the fonts init_fonts(); check_gl_errors(); //load the necesary textures //font_text=load_texture_cache("./textures/font.bmp",0); icons_text=load_texture_cache("./textures/gamebuttons.bmp",0); hud_text=load_texture_cache("./textures/gamebuttons2.bmp",0); cons_text=load_texture_cache("./textures/console.bmp",255); sky_text_1=load_texture_cache("./textures/sky.bmp",70); particle_textures[0]=load_texture_cache("./textures/particle0.bmp",0); particle_textures[1]=load_texture_cache("./textures/particle1.bmp",0); particle_textures[2]=load_texture_cache("./textures/particle2.bmp",0); particle_textures[3]=load_texture_cache("./textures/particle3.bmp",0); particle_textures[4]=load_texture_cache("./textures/particle4.bmp",0); particle_textures[5]=load_texture_cache("./textures/particle5.bmp",0); particle_textures[6]=load_texture_cache("./textures/particle6.bmp",0); particle_textures[7]=load_texture_cache("./textures/particle7.bmp",0); items_text_1=load_texture_cache("./textures/items1.bmp",0); items_text_2=load_texture_cache("./textures/items2.bmp",0); items_text_3=load_texture_cache("./textures/items3.bmp",0); items_text_4=load_texture_cache("./textures/items4.bmp",0); items_text_5=load_texture_cache("./textures/items5.bmp",0); items_text_6=load_texture_cache("./textures/items6.bmp",0); items_text_7=load_texture_cache("./textures/items7.bmp",0); items_text_8=load_texture_cache("./textures/items8.bmp",0); items_text_9=load_texture_cache("./textures/items9.bmp",0); portraits1_tex=load_texture_cache("./textures/portraits1.bmp",0); portraits2_tex=load_texture_cache("./textures/portraits2.bmp",0); portraits3_tex=load_texture_cache("./textures/portraits3.bmp",0); portraits4_tex=load_texture_cache("./textures/portraits4.bmp",0); portraits5_tex=load_texture_cache("./textures/portraits5.bmp",0); halo_tex=load_texture_cache("./textures/halo.bmp",0); if(have_multitexture)ground_detail_text=load_texture_cache("./textures/ground_detail.bmp",255); check_gl_errors(); create_char_error_str[0]=0; init_opening_interface(); init_hud_interface(); if(SDLNet_Init()<0) { char str[120]; sprintf(str,"%s: %s\n",failed_sdl_net_init,SDLNet_GetError()); log_error(str); SDLNet_Quit(); SDL_Quit(); exit(2); } if(SDL_InitSubSystem(SDL_INIT_TIMER)<0) { char str[120]; sprintf(str, "%s: %s\n", failed_sdl_timer_init,SDL_GetError()); log_error(str); SDL_Quit(); exit(1); } SDL_SetTimer (1000/(18*4), my_timer_pointer); ReadXML("languages/en/Encyclopedia/index.xml"); read_key_config(); load_questlog(); init_buddy(); //initiate function pointers init_attribf(); //we might want to do this later. connect_to_server(); }
void set_new_video_mode(int fs,int mode) { int i; #ifndef NEW_TEXTURES int alpha; #endif /* NEW_TEXTURES */ full_screen=fs; video_mode=mode; //now, clear all the textures... #ifdef NEW_TEXTURES unload_texture_cache(); #else /* NEW_TEXTURES */ for(i = 0; i < TEXTURE_CACHE_MAX; i++) { if(texture_cache[i].file_name[0]) { glDeleteTextures(1,(GLuint*)&texture_cache[i].texture_id); texture_cache[i].texture_id=0;//force a reload CHECK_GL_ERRORS(); } } #ifndef MAP_EDITOR2 //do the same for the actors textures... for(i=0;i<max_actors;i++) { if(actors_list[i]) { if(actors_list[i]->remapped_colors || actors_list[i]->is_enhanced_model)//if it is not remapable, then it is already in the cache { glDeleteTextures(1,&actors_list[i]->texture_id); actors_list[i]->texture_id=0; CHECK_GL_ERRORS(); } } } #endif #endif /* NEW_TEXTURES */ if (use_vertex_buffers) { e3d_object * obj; #ifdef FASTER_MAP_LOAD for (i = 0; i < cache_e3d->num_items; i++) #else for (i = 0; i < cache_e3d->max_item; i++) #endif { if (!cache_e3d->cached_items[i]) continue; obj= cache_e3d->cached_items[i]->cache_item; free_e3d_va(obj); } CHECK_GL_ERRORS(); } #ifndef NEW_TEXTURES ec_clear_textures(); #endif /* NEW_TEXTURES */ //destroy the current context init_video(); #ifndef WINDOWS // Re-enable window manager events, since the killing of the video // subsystem turns them off. SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE); #endif resize_root_window(); init_lights(); disable_local_lights(); reset_material(); //reload the cursors load_cursors(); build_cursors(); change_cursor(current_cursor); ec_load_textures(); //now, reload the textures #ifndef NEW_TEXTURES for(i = 0; i < TEXTURE_CACHE_MAX; i++) { if (texture_cache[i].file_name[0] && !texture_cache[i].load_err) { alpha=texture_cache[i].alpha; //our texture was freed, we have to reload it if(alpha<=0) texture_cache[i].texture_id = load_bmp8_color_key (&(texture_cache[i]), alpha); else texture_cache[i].texture_id = load_bmp8_fixed_alpha (&(texture_cache[i]), alpha); } } reload_fonts(); #ifndef MAP_EDITOR2 //do the same for the actors textures... for(i=0;i<max_actors;i++) { if(actors_list[i]) { if(actors_list[i]->remapped_colors)//if it is not remapable, then it is already in the cache { //reload the skin //actors_list[i]->texture_id=load_bmp8_remapped_skin(actors_list[i]->skin_name, // 150,actors_list[i]->skin,actors_list[i]->hair,actors_list[i]->shirt, // actors_list[i]->pants,actors_list[i]->boots); } if(actors_list[i]->is_enhanced_model) { actors_list[i]->texture_id=load_bmp8_enhanced_actor(actors_list[i]->body_parts, 255); } } } #endif #endif /* NEW_TEXTURES */ //it is dependent on the window height... init_hud_interface (HUD_INTERFACE_LAST); new_minute(); set_all_intersect_update_needed(main_bbox_tree); skybox_init_gl(); // resize the EL root windows resize_all_root_windows (window_width, window_height); check_options(); reload_tab_map = 1; #ifdef NEW_CURSOR if (!sdl_cursors) { SDL_ShowCursor(0); SDL_WM_GrabInput(SDL_GRAB_OFF); } #endif // NEW_CURSOR }
int main( int argc, char **argv ) { if ( use_gui ) { printf("init_sdl()\n"); if ( init_sdl() ) return 1; printf("init_gl()\n"); init_gl(); } printf("init_fft()\n"); init_fft(); #ifdef USE_FIFO printf("init_mpd()\n"); if ( init_mpd() ) return 1; #endif #ifdef USE_ALSA printf("init_alsa()\n"); if ( init_alsa() ) return 1; #endif if ( use_serial ) { printf("init_serial()\n"); if ( init_serial() ) use_serial = FALSE; } init_lights(); init_table(); pthread_t sample_thread; pthread_create(&sample_thread, NULL, &get_samples, NULL); while ( !done ) { // check to see if we have a new sample if (new_sample == 1) { // we are going to process this sample, it is no longer new pthread_mutex_lock(&sample_mutex); new_sample = 0; pthread_mutex_unlock(&sample_mutex); do_fft(); detect_beats(); assign_lights(); //assign_cells(); if ( use_gui ) { if (handle_sdl_events()) return 1; draw_all(); } if ( use_serial ) send_serial_fpga(); } usleep(5000); } return 0; }