NodeDisplayData::~NodeDisplayData() { #ifdef BOGUS printf ("~~~ NodeDisplayData Destructed ~~~\n"); delete f_model; f_locator_table.remove_all (TRUE); ON_DEBUG(cerr << f_node_object.locator() << endl); graphics_mgr().remove(f_node_object); #endif }
void NodeDisplayData::not_displayed() { return; // commented out to test code below // NOTE: Return for now - improves performance, but uses more memory. // If you remove the return statement above you MUST tell me // or user marks will break!! DJB 10/28/92 #if 0 delete f_model; f_model = NULL; f_locator_table.remove_all (TRUE); graphics_mgr().remove(f_node_object); #endif }
int main(int argc,char** args) { srand(time(NULL)); try { if (SDL_Init(SDL_INIT_VIDEO)) { fprintf(stderr,"Unable to initialize SDL: %s\n",SDL_GetError()); return EXIT_FAILURE; } atexit(SDL_Quit); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1); #if 0 screen = SDL_SetVideoMode(1440,900,32,SDL_OPENGL|SDL_FULLSCREEN); #else screen = SDL_SetVideoMode(1024,768,32,SDL_OPENGL/*|SDL_FULLSCREEN*/); #endif if(!screen) { fprintf(stderr,"Unable to create SDL screen: %s\n",SDL_GetError()); return EXIT_FAILURE; } SDL_WM_SetCaption("GlestNG","GlestNG"); GLenum err = glewInit(); if(GLEW_OK != err) { fprintf(stderr, "Error: %s\n", glewGetErrorString(err)); return EXIT_FAILURE; } fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); // we have a GL context so we can go ahead and init all the singletons std::auto_ptr<fs_t> fs_settings(fs_t::create("data/")); fs_t::settings = fs_settings.get(); // set it globally std::auto_ptr<xml_parser_t> xml_settings(new xml_parser_t("UI Settings",fs_settings->get_body("ui_settings.xml"))); xml_settings->set_as_settings(); std::auto_ptr<graphics_t::mgr_t> graphics_mgr(graphics_t::create()); std::auto_ptr<fonts_t> fonts(fonts_t::create()); std::auto_ptr<fs_t> fs; try { fs.reset(fs_t::create("data/Glest")); if(false) { fs_file_t::ptr_t logo_file(fs_settings->get("logo.g3d")); istream_t::ptr_t logostream(logo_file->reader()); logo = std::auto_ptr<model_g3d_t>(new model_g3d_t(*logostream)); } load(*fs); } catch(glest_exception_t* e) { std::cerr << "cannot load glest data: " << e << std::endl; delete e; } std::auto_ptr<ui_mgr_t> ui_(ui_mgr()); std::auto_ptr<mod_ui_t> mod_ui(mod_ui_t::create()); std::auto_ptr<terrain_t> terrain(terrain_t::gen_planet(5,500,3)); //world()->dump(std::cout); v4_t light_amb(0,0,0,1), light_dif(1.,1.,1.,1.), light_spec(1.,1.,1.,1.), light_pos(1.,1.,-1.,0.), mat_amb(.7,.7,.7,1.), mat_dif(.8,.8,.8,1.), mat_spec(1.,1.,1.,1.); glLightfv(GL_LIGHT0,GL_AMBIENT,light_amb.v); glLightfv(GL_LIGHT0,GL_DIFFUSE,light_dif.v); glLightfv(GL_LIGHT0,GL_SPECULAR,light_spec.v); glLightfv(GL_LIGHT0,GL_POSITION,light_pos.v); glLightfv(GL_LIGHT1,GL_AMBIENT,light_amb.v); glLightfv(GL_LIGHT1,GL_DIFFUSE,light_dif.v); glLightfv(GL_LIGHT1,GL_SPECULAR,light_spec.v); glMaterialfv(GL_FRONT,GL_AMBIENT,mat_amb.v); glMaterialfv(GL_FRONT,GL_DIFFUSE,mat_dif.v); glMaterialfv(GL_FRONT,GL_SPECULAR,mat_spec.v); glMaterialf(GL_FRONT,GL_SHININESS,100.0); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glDepthFunc(GL_LEQUAL); glEnable(GL_DEPTH_TEST); glAlphaFunc(GL_GREATER,0.4); glEnable(GL_COLOR_MATERIAL); glEnable(GL_RESCALE_NORMAL); glEnable(GL_BLEND); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColorMaterial(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); glEnable(GL_NORMALIZE); glFrontFace(GL_CW); camera(); bool quit = false; SDL_Event event; SDL_EnableKeyRepeat(200,20); SDL_EnableUNICODE(true); const unsigned start = SDL_GetTicks(); framerate.reset(); while(!quit) { set_now(SDL_GetTicks()-start); while(!quit && SDL_PollEvent(&event)) { if(ui_mgr()->offer(event)) continue; switch (event.type) { case SDL_MOUSEMOTION: if(selection) std::cout << "drag" << std::endl; /*printf("Mouse moved by %d,%d to (%d,%d)\n", event.motion.xrel, event.motion.yrel, event.motion.x, event.motion.y);*/ break; case SDL_MOUSEBUTTONDOWN: click(event.button.x,event.button.y); if(selection) std::cout << "selection: "<<selected_point<<std::endl; break; case SDL_MOUSEBUTTONUP: if(selection) std::cout << "selection stopped" << std::endl; selection = false; break; case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_PLUS: zoom += 1; camera(); break; case SDLK_MINUS: zoom -= 1; camera(); break; case SDLK_ESCAPE: quit = true; break; case SDLK_m: // MODDING MODE if(!fs.get()) { std::cerr << "(modding menu triggered but mod not loaded)" << std::endl; break; } if(mod_ui->is_shown()) mod_ui->hide(); else mod_ui->show(ref_t(*techtree,TECHTREE,techtree->name)); break; default: std::cout << "Ignoring key " << (int)event.key.keysym.scancode << "," << event.key.keysym.sym << "," << event.key.keysym.mod << "," << event.key.keysym.unicode << std::endl; } break; case SDL_QUIT: quit = true; break; } } framerate.tick(now()); tick(); } for(tests_t::iterator i=objs.begin(); i!=objs.end(); i++) delete *i; return EXIT_SUCCESS; } catch(data_error_t* de) { std::cerr << "Oh! " << de << std::endl; } catch(graphics_error_t* ge) { std::cerr << "Oh! " << ge << std::endl; } catch(panic_t* panic) { std::cerr << "Oh! " << panic << std::endl; } return EXIT_FAILURE; }