void mouse(int button, int state, int x, int y) { if (state == GLUT_DOWN) { moffsetx = x; moffsety = y; } if (button == 3) { // zoom:=12 for all earth?? int zoom = (int)floor(center.zoom+0.5); crd_zoomby(¢er,0.05); if(lastzoom!=zoom){ lastzoom = zoom; //fprintf(stderr,"zoom:%d\n",lastzoom); } make_tiles(); glutPostRedisplay(); } else if (button == 4) { int zoom = (int)floor(center.zoom+0.5); crd_zoomby(¢er,-0.05); if(lastzoom!=zoom){ lastzoom = zoom; //fprintf(stderr,"zoom:%d\n",lastzoom); } make_tiles(); glutPostRedisplay(); } }
void mousemove(int x,int y) { int ox = moffsetx - x; int oy = moffsety - y; moffsetx = x; moffsety = y; center.column += ox/256.0; center.row += oy/256.0; make_tiles(); glutPostRedisplay(); }
RS::Bundle::Bundle(Main &main, OCamlBinding &ocaml) : tiles(make_tiles()) , act(WIN_SIZEVI) { ftui::Activity &act = this->act; auto pushFun = [&](std::string const &fname, lua_CFunction f) { act.registerLuaCFun_table("ResultState", fname, f); }; std::ifstream is("res/layout/result_state.xml"); act.inflate(is); main.loadSharedScripts(act); luaL_dostring(act.getLuaState() , "ResultState = {}; GridColor = 0x0000FF;"); pushFun("tagForLeave", &tagForLeaveG); this->act.fireEvent("ON_GAME_LOADED"); return ; }
PS::Bundle::Bundle(Main &main, OCamlBinding &ocaml) : tiles(make_tiles()) , act(WIN_SIZEVI) , selectedId(0) , grids({Grid::def}) { ftui::Activity &act = this->act; auto pushFun = [&](std::string const &fname, lua_CFunction f) { act.registerLuaCFun_table("PickState", fname, f); }; std::ifstream is("res/layout/pick_state.xml"); Grid *gr; act.inflate(is); main.loadSharedScripts(act); luaL_dostring(act.getLuaState() , "PickState = {}; GridColor = 0x0000FF;"); pushFun("selectGrid", &selectGridG); pushFun("deleteGrid", &deleteGridG); pushFun("pushRandomGrid", &pushRandomGridG); pushFun("getNumGrids", &getNumGridsG); pushFun("getGridName", &getGridNameG); pushFun("getGrid", &getGridG); pushFun("getMainGridId", &getMainGridIdG); pushFun("useDefaultGrid", &useDefaultGridG); pushFun("setAlgorithmId", &setAlgorithmIdG); pushFun("setHeuristicId", &setHeuristicIdG); pushFun("setCost", &setCostG); pushFun("tagForSolving", &tagForSolvingG); for (auto const &fileName : main.files) { this->grids.emplace_back(fileName); gr = &this->grids[this->grids.size() - 1]; gr->convert(ocaml.transposition_toabstract(gr->getSize())); } // this->act.fireEvent("GRID_LIST_UPDATE", this->extractGridNames() // , this->grids.size()); this->act.fireEvent("ON_GAME_LOADED"); return ; }
int main(int argc, char* argv[]) { thrd_t thrd1,thrd2,thrd3,thrd4; time_t tm; srand((unsigned int)time(&tm)); curl_global_init(CURL_GLOBAL_WIN32/*CURL_GLOBAL_DEFAULT*/);// without ssl //initMqcdnMap(&map); //initOSMMap(&map); initBingMap(&map); //initYahooMap(&map); //not work //initYndexMap(&map); glutInitWindowSize(veiwport[0], veiwport[1]); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("glutplanet"); glutMouseFunc(mouse); glutMotionFunc(mousemove); glutIdleFunc(idle); glutReshapeFunc(reshape); glutDisplayFunc(draw); tiles = make_list(); tiles_get = make_synclist(); thrd_create(&thrd1,worker_thread,0); thrd_create(&thrd2,worker_thread,0); thrd_create(&thrd3,worker_thread,0); thrd_create(&thrd4,worker_thread,0); crd_setz(¢er,0.5,0.5,0); //double z = log2(veiwport[0]<veiwport[1]?veiwport[0]:veiwport[1] / 256.0); crd_zoomto(¢er,log2(veiwport[0]<veiwport[1]?veiwport[0]:veiwport[1] / 256.0)); make_tiles(); atexit(do_exit); glutMainLoop(); return 0; }