example.cpp 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. #include "draw_skeleton.h"
  2. #include <igl/two_axis_valuator_fixed_up.h>
  3. #include <igl/readOBJ.h>
  4. #include <igl/readTGF.h>
  5. #include <igl/writeOBJ.h>
  6. #include <igl/writeOFF.h>
  7. #include <igl/readWRL.h>
  8. #include <igl/report_gl_error.h>
  9. #include <igl/triangulate.h>
  10. #include <igl/readOFF.h>
  11. #include <igl/readMESH.h>
  12. #include <igl/draw_mesh.h>
  13. #include <igl/draw_floor.h>
  14. #include <igl/pathinfo.h>
  15. #include <igl/list_to_matrix.h>
  16. #include <igl/quat_to_mat.h>
  17. #include <igl/per_face_normals.h>
  18. #include <igl/material_colors.h>
  19. #include <igl/trackball.h>
  20. #include <igl/snap_to_canonical_view_quat.h>
  21. #include <igl/snap_to_fixed_up.h>
  22. #include <igl/REDRUM.h>
  23. #include <igl/Camera.h>
  24. #include <igl/ReAntTweakBar.h>
  25. #include <igl/get_seconds.h>
  26. #include <igl/forward_kinematics.h>
  27. #include <igl/tetgen/mesh_with_skeleton.h>
  28. #include <igl/boundary_conditions.h>
  29. #include <igl/normalize_row_sums.h>
  30. #include <igl/lbs_matrix.h>
  31. #include <igl/bbw/bbw.h>
  32. #include <Eigen/Core>
  33. #include <Eigen/Geometry>
  34. #include <GLUT/glut.h>
  35. #include <string>
  36. #include <vector>
  37. #include <stack>
  38. #include <iostream>
  39. Eigen::MatrixXd V,N,C,W,M;
  40. Eigen::VectorXd Vmid,Vmin,Vmax;
  41. double bbd = 1.0;
  42. Eigen::MatrixXi F,BE;
  43. Eigen::VectorXi P;
  44. struct State
  45. {
  46. igl::Camera camera;
  47. } s;
  48. bool wireframe = false;
  49. bool skeleton_on_top = false;
  50. // See README for descriptions
  51. enum RotationType
  52. {
  53. ROTATION_TYPE_IGL_TRACKBALL = 0,
  54. ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP = 1,
  55. NUM_ROTATION_TYPES = 2,
  56. } rotation_type;
  57. std::stack<State> undo_stack;
  58. std::stack<State> redo_stack;
  59. bool is_rotating = false;
  60. int down_x,down_y;
  61. igl::Camera down_camera;
  62. bool is_animating = false;
  63. double animation_start_time = 0;
  64. double ANIMATION_DURATION = 0.5;
  65. Eigen::Quaterniond animation_from_quat;
  66. Eigen::Quaterniond animation_to_quat;
  67. int width,height;
  68. Eigen::Vector4f light_pos(-0.1,-0.1,0.9,0);
  69. #define REBAR_NAME "temp.rbr"
  70. igl::ReTwBar rebar;
  71. void push_undo()
  72. {
  73. undo_stack.push(s);
  74. // Clear
  75. redo_stack = std::stack<State>();
  76. }
  77. // No-op setter, does nothing
  78. void TW_CALL no_op(const void * /*value*/, void * /*clientData*/)
  79. {
  80. }
  81. void TW_CALL set_rotation_type(const void * value, void * clientData)
  82. {
  83. using namespace Eigen;
  84. using namespace std;
  85. using namespace igl;
  86. const RotationType old_rotation_type = rotation_type;
  87. rotation_type = *(const RotationType *)(value);
  88. if(rotation_type == ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP &&
  89. old_rotation_type != ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP)
  90. {
  91. push_undo();
  92. animation_from_quat = s.camera.m_rotation_conj;
  93. snap_to_fixed_up(animation_from_quat,animation_to_quat);
  94. // start animation
  95. animation_start_time = get_seconds();
  96. is_animating = true;
  97. }
  98. }
  99. void TW_CALL get_rotation_type(void * value, void *clientData)
  100. {
  101. RotationType * rt = (RotationType *)(value);
  102. *rt = rotation_type;
  103. }
  104. void reshape(int width, int height)
  105. {
  106. ::width = width;
  107. ::height = height;
  108. glViewport(0,0,width,height);
  109. // Send the new window size to AntTweakBar
  110. TwWindowSize(width, height);
  111. s.camera.m_aspect = (double)width/(double)height;
  112. }
  113. void push_scene()
  114. {
  115. using namespace igl;
  116. using namespace std;
  117. glMatrixMode(GL_PROJECTION);
  118. glPushMatrix();
  119. glLoadIdentity();
  120. auto & camera = s.camera;
  121. gluPerspective(camera.m_angle,camera.m_aspect,camera.m_near,camera.m_far);
  122. glMatrixMode(GL_MODELVIEW);
  123. glPushMatrix();
  124. glLoadIdentity();
  125. gluLookAt(
  126. camera.eye()(0), camera.eye()(1), camera.eye()(2),
  127. camera.at()(0), camera.at()(1), camera.at()(2),
  128. camera.up()(0), camera.up()(1), camera.up()(2));
  129. }
  130. void push_object()
  131. {
  132. using namespace igl;
  133. glPushMatrix();
  134. glScaled(2./bbd,2./bbd,2./bbd);
  135. glTranslated(-Vmid(0),-Vmid(1),-Vmid(2));
  136. }
  137. void pop_object()
  138. {
  139. glPopMatrix();
  140. }
  141. void pop_scene()
  142. {
  143. glMatrixMode(GL_PROJECTION);
  144. glPopMatrix();
  145. glMatrixMode(GL_MODELVIEW);
  146. glPopMatrix();
  147. }
  148. // Set up double-sided lights
  149. void lights()
  150. {
  151. using namespace std;
  152. using namespace Eigen;
  153. glEnable(GL_LIGHTING);
  154. glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
  155. glEnable(GL_LIGHT0);
  156. glEnable(GL_LIGHT1);
  157. float WHITE[4] = {0.8,0.8,0.8,1.};
  158. float GREY[4] = {0.4,0.4,0.4,1.};
  159. float BLACK[4] = {0.,0.,0.,1.};
  160. Vector4f pos = light_pos;
  161. glLightfv(GL_LIGHT0,GL_AMBIENT,GREY);
  162. glLightfv(GL_LIGHT0,GL_DIFFUSE,WHITE);
  163. glLightfv(GL_LIGHT0,GL_SPECULAR,BLACK);
  164. glLightfv(GL_LIGHT0,GL_POSITION,pos.data());
  165. pos(0) *= -1;
  166. pos(1) *= -1;
  167. pos(2) *= -1;
  168. glLightfv(GL_LIGHT1,GL_AMBIENT,GREY);
  169. glLightfv(GL_LIGHT1,GL_DIFFUSE,WHITE);
  170. glLightfv(GL_LIGHT1,GL_SPECULAR,BLACK);
  171. glLightfv(GL_LIGHT1,GL_POSITION,pos.data());
  172. }
  173. void display()
  174. {
  175. using namespace igl;
  176. using namespace std;
  177. using namespace Eigen;
  178. const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
  179. glClearColor(back[0],back[1],back[2],0);
  180. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  181. if(is_animating)
  182. {
  183. double t = (get_seconds() - animation_start_time)/ANIMATION_DURATION;
  184. if(t > 1)
  185. {
  186. t = 1;
  187. is_animating = false;
  188. }
  189. Quaterniond q = animation_from_quat.slerp(t,animation_to_quat).normalized();
  190. auto & camera = s.camera;
  191. camera.orbit(q.conjugate());
  192. }
  193. glEnable(GL_DEPTH_TEST);
  194. glEnable(GL_NORMALIZE);
  195. lights();
  196. push_scene();
  197. // Draw a nice floor
  198. glEnable(GL_DEPTH_TEST);
  199. glPushMatrix();
  200. const double floor_offset =
  201. -2./bbd*(V.col(1).maxCoeff()-Vmid(1));
  202. glTranslated(0,floor_offset,0);
  203. const float GREY[4] = {0.5,0.5,0.6,1.0};
  204. const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
  205. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  206. draw_floor(GREY,DARK_GREY);
  207. glPopMatrix();
  208. push_object();
  209. // Set material properties
  210. glDisable(GL_COLOR_MATERIAL);
  211. glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, SILVER_AMBIENT);
  212. glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, SILVER_DIFFUSE );
  213. glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SILVER_SPECULAR);
  214. glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 128);
  215. vector<Quaterniond> dQ(BE.rows(),Quaterniond::Identity()),vQ;
  216. vector<Vector3d> vT;
  217. Matrix3d A = Matrix3d::Identity();
  218. for(int e = 0;e<BE.rows();e++)
  219. {
  220. dQ[e] = AngleAxisd((sin(get_seconds()+e))*0.06*PI,A.col(e%3));
  221. }
  222. forward_kinematics(C,BE,P,dQ,vQ,vT);
  223. const int dim = C.cols();
  224. MatrixXd T(BE.rows()*(dim+1),dim);
  225. for(int e = 0;e<BE.rows();e++)
  226. {
  227. Affine3d a = Affine3d::Identity();
  228. a.translate(vT[e]);
  229. a.rotate(vQ[e]);
  230. T.block(e*(dim+1),0,dim+1,dim) =
  231. a.matrix().transpose().block(0,0,dim+1,dim);
  232. }
  233. if(wireframe)
  234. {
  235. glPolygonMode(GL_FRONT_AND_BACK,GL_LINE);
  236. }
  237. glLineWidth(1.0);
  238. MatrixXd U = M*T;
  239. per_face_normals(U,F,N);
  240. draw_mesh(U,F,N);
  241. glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
  242. if(skeleton_on_top)
  243. {
  244. glDisable(GL_DEPTH_TEST);
  245. }
  246. draw_skeleton(C,BE,T);
  247. pop_object();
  248. pop_scene();
  249. report_gl_error();
  250. TwDraw();
  251. glutSwapBuffers();
  252. glutPostRedisplay();
  253. }
  254. void mouse_wheel(int wheel, int direction, int mouse_x, int mouse_y)
  255. {
  256. using namespace std;
  257. using namespace igl;
  258. using namespace Eigen;
  259. GLint viewport[4];
  260. glGetIntegerv(GL_VIEWPORT,viewport);
  261. if(wheel == 0 && TwMouseMotion(mouse_x, viewport[3] - mouse_y))
  262. {
  263. static double mouse_scroll_y = 0;
  264. const double delta_y = 0.125*direction;
  265. mouse_scroll_y += delta_y;
  266. TwMouseWheel(mouse_scroll_y);
  267. return;
  268. }
  269. push_undo();
  270. auto & camera = s.camera;
  271. if(wheel==0)
  272. {
  273. // factor of zoom change
  274. double s = (1.-0.01*direction);
  275. //// FOV zoom: just widen angle. This is hardly ever appropriate.
  276. //camera.m_angle *= s;
  277. //camera.m_angle = min(max(camera.m_angle,1),89);
  278. camera.push_away(s);
  279. }else
  280. {
  281. // Dolly zoom:
  282. camera.dolly_zoom((double)direction*1.0);
  283. }
  284. }
  285. void mouse(int glutButton, int glutState, int mouse_x, int mouse_y)
  286. {
  287. using namespace std;
  288. using namespace Eigen;
  289. using namespace igl;
  290. bool tw_using = TwEventMouseButtonGLUT(glutButton,glutState,mouse_x,mouse_y);
  291. switch(glutButton)
  292. {
  293. case GLUT_RIGHT_BUTTON:
  294. case GLUT_LEFT_BUTTON:
  295. {
  296. switch(glutState)
  297. {
  298. case 1:
  299. // up
  300. glutSetCursor(GLUT_CURSOR_INHERIT);
  301. is_rotating = false;
  302. break;
  303. case 0:
  304. if(!tw_using)
  305. {
  306. push_undo();
  307. glutSetCursor(GLUT_CURSOR_CYCLE);
  308. // collect information for trackball
  309. is_rotating = true;
  310. down_camera = s.camera;
  311. down_x = mouse_x;
  312. down_y = mouse_y;
  313. }
  314. break;
  315. }
  316. break;
  317. }
  318. // Scroll down
  319. case 3:
  320. {
  321. mouse_wheel(0,-1,mouse_x,mouse_y);
  322. break;
  323. }
  324. // Scroll up
  325. case 4:
  326. {
  327. mouse_wheel(0,1,mouse_x,mouse_y);
  328. break;
  329. }
  330. // Scroll left
  331. case 5:
  332. {
  333. mouse_wheel(1,-1,mouse_x,mouse_y);
  334. break;
  335. }
  336. // Scroll right
  337. case 6:
  338. {
  339. mouse_wheel(1,1,mouse_x,mouse_y);
  340. break;
  341. }
  342. }
  343. }
  344. void mouse_drag(int mouse_x, int mouse_y)
  345. {
  346. using namespace igl;
  347. using namespace std;
  348. using namespace Eigen;
  349. if(is_rotating)
  350. {
  351. glutSetCursor(GLUT_CURSOR_CYCLE);
  352. Quaterniond q;
  353. auto & camera = s.camera;
  354. switch(rotation_type)
  355. {
  356. case ROTATION_TYPE_IGL_TRACKBALL:
  357. {
  358. // Rotate according to trackball
  359. igl::trackball<double>(
  360. width,
  361. height,
  362. 2.0,
  363. down_camera.m_rotation_conj.coeffs().data(),
  364. down_x,
  365. down_y,
  366. mouse_x,
  367. mouse_y,
  368. q.coeffs().data());
  369. break;
  370. }
  371. case ROTATION_TYPE_TWO_AXIS_VALUATOR_FIXED_UP:
  372. {
  373. // Rotate according to two axis valuator with fixed up vector
  374. two_axis_valuator_fixed_up(
  375. width, height,
  376. 2.0,
  377. down_camera.m_rotation_conj,
  378. down_x, down_y, mouse_x, mouse_y,
  379. q);
  380. break;
  381. }
  382. default:
  383. break;
  384. }
  385. camera.orbit(q.conjugate());
  386. }
  387. }
  388. void init_relative()
  389. {
  390. using namespace Eigen;
  391. using namespace igl;
  392. per_face_normals(V,F,N);
  393. Vmax = V.colwise().maxCoeff();
  394. Vmin = V.colwise().minCoeff();
  395. Vmid = 0.5*(Vmax + Vmin);
  396. bbd = (Vmax-Vmin).norm();
  397. }
  398. void undo()
  399. {
  400. using namespace std;
  401. if(!undo_stack.empty())
  402. {
  403. redo_stack.push(s);
  404. s = undo_stack.top();
  405. undo_stack.pop();
  406. }
  407. }
  408. void redo()
  409. {
  410. using namespace std;
  411. if(!redo_stack.empty())
  412. {
  413. undo_stack.push(s);
  414. s = redo_stack.top();
  415. redo_stack.pop();
  416. }
  417. }
  418. void key(unsigned char key, int mouse_x, int mouse_y)
  419. {
  420. using namespace std;
  421. using namespace igl;
  422. using namespace Eigen;
  423. int mod = glutGetModifiers();
  424. const bool command_down = GLUT_ACTIVE_COMMAND & mod;
  425. const bool shift_down = GLUT_ACTIVE_SHIFT & mod;
  426. switch(key)
  427. {
  428. // ESC
  429. case char(27):
  430. rebar.save(REBAR_NAME);
  431. // ^C
  432. case char(3):
  433. exit(0);
  434. case 'z':
  435. case 'Z':
  436. if(command_down)
  437. {
  438. if(shift_down)
  439. {
  440. redo();
  441. }else
  442. {
  443. undo();
  444. }
  445. break;
  446. }else
  447. {
  448. push_undo();
  449. Quaterniond q;
  450. snap_to_canonical_view_quat(s.camera.m_rotation_conj,1.0,q);
  451. s.camera.orbit(q.conjugate());
  452. }
  453. default:
  454. if(!TwEventKeyboardGLUT(key,mouse_x,mouse_y))
  455. {
  456. cout<<"Unknown key command: "<<key<<" "<<int(key)<<endl;
  457. }
  458. }
  459. }
  460. bool init_weights(
  461. const Eigen::MatrixXd & V,
  462. const Eigen::MatrixXi & F,
  463. const Eigen::MatrixXd & C,
  464. const Eigen::MatrixXi & BE,
  465. Eigen::MatrixXd & W)
  466. {
  467. using namespace igl;
  468. using namespace Eigen;
  469. // Mesh with samples on skeleton
  470. // New vertices of tet mesh, V prefaces VV
  471. MatrixXd VV;
  472. MatrixXi TT,FF,CE;
  473. VectorXi P;
  474. if(!mesh_with_skeleton(V,F,C,P,BE,CE,10,VV,TT,FF))
  475. {
  476. return false;
  477. }
  478. // List of boundary indices (aka fixed value indices into VV)
  479. VectorXi b;
  480. // List of boundary conditions of each weight function
  481. MatrixXd bc;
  482. if(!boundary_conditions(VV,TT,C,P,BE,CE,b,bc))
  483. {
  484. return false;
  485. }
  486. // compute BBW
  487. // Default bbw data and flags
  488. BBWData bbw_data;
  489. bbw_data.active_set_params.max_iter = 4;
  490. // Weights matrix
  491. if(!bbw(VV,TT,b,bc,bbw_data,W))
  492. {
  493. return false;
  494. }
  495. // Normalize weights to sum to one
  496. normalize_row_sums(W,W);
  497. W.conservativeResize(V.rows(),W.cols());
  498. return true;
  499. }
  500. int main(int argc, char * argv[])
  501. {
  502. using namespace std;
  503. using namespace Eigen;
  504. using namespace igl;
  505. string filename = "../shared/cheburashka.obj";
  506. string skel_filename = "../shared/cheburashka.tgf";
  507. if(argc < 3)
  508. {
  509. cerr<<"Usage:"<<endl<<" ./example input.obj"<<endl;
  510. cout<<endl<<"Opening default mesh..."<<endl;
  511. }else
  512. {
  513. // Read and prepare mesh
  514. filename = argv[1];
  515. skel_filename = argv[2];
  516. }
  517. // print key commands
  518. cout<<"[Click] and [drag] Rotate model using trackball."<<endl;
  519. cout<<"[Z,z] Snap rotation to canonical view."<<endl;
  520. cout<<"[⌘ Z] Undo."<<endl;
  521. cout<<"[⇧ ⌘ Z] Redo."<<endl;
  522. cout<<"[^C,ESC] Exit."<<endl;
  523. // dirname, basename, extension and filename
  524. string d,b,ext,f;
  525. pathinfo(filename,d,b,ext,f);
  526. // Convert extension to lower case
  527. transform(ext.begin(), ext.end(), ext.begin(), ::tolower);
  528. vector<vector<double > > vV,vN,vTC;
  529. vector<vector<int > > vF,vFTC,vFN;
  530. if(ext == "obj")
  531. {
  532. // Convert extension to lower case
  533. if(!igl::readOBJ(filename,vV,vTC,vN,vF,vFTC,vFN))
  534. {
  535. return 1;
  536. }
  537. }else if(ext == "off")
  538. {
  539. // Convert extension to lower case
  540. if(!igl::readOFF(filename,vV,vF,vN))
  541. {
  542. return 1;
  543. }
  544. }else if(ext == "wrl")
  545. {
  546. // Convert extension to lower case
  547. if(!igl::readWRL(filename,vV,vF))
  548. {
  549. return 1;
  550. }
  551. //}else
  552. //{
  553. // // Convert extension to lower case
  554. // MatrixXi T;
  555. // if(!igl::readMESH(filename,V,T,F))
  556. // {
  557. // return 1;
  558. // }
  559. // //if(F.size() > T.size() || F.size() == 0)
  560. // {
  561. // boundary_faces(T,F);
  562. // }
  563. }
  564. if(vV.size() > 0)
  565. {
  566. if(!list_to_matrix(vV,V))
  567. {
  568. return 1;
  569. }
  570. triangulate(vF,F);
  571. }
  572. readTGF(skel_filename,C,BE);
  573. // Recover parent indices because (C,BE) is crappy format for a tree.
  574. P.resize(BE.rows(),1);
  575. for(int e = 0;e<BE.rows();e++)
  576. {
  577. P(e) = -1;
  578. for(int f = 0;f<BE.rows();f++)
  579. {
  580. if(BE(e,0) == BE(f,1))
  581. {
  582. P(e) = f;
  583. }
  584. }
  585. }
  586. init_weights(V,F,C,BE,W);
  587. lbs_matrix(V,W,M);
  588. init_relative();
  589. // Init glut
  590. glutInit(&argc,argv);
  591. if( !TwInit(TW_OPENGL, NULL) )
  592. {
  593. // A fatal error occured
  594. fprintf(stderr, "AntTweakBar initialization failed: %s\n", TwGetLastError());
  595. return 1;
  596. }
  597. // Create a tweak bar
  598. rebar.TwNewBar("TweakBar");
  599. rebar.TwAddVarRW("camera_rotation", TW_TYPE_QUAT4D,
  600. s.camera.m_rotation_conj.coeffs().data(), "open readonly=true");
  601. TwType RotationTypeTW = ReTwDefineEnumFromString("RotationType",
  602. "igl_trackball,two-a...-fixed-up");
  603. rebar.TwAddVarCB( "rotation_type", RotationTypeTW,
  604. set_rotation_type,get_rotation_type,NULL,"keyIncr=] keyDecr=[");
  605. rebar.TwAddVarRW("skeleton_on_top", TW_TYPE_BOOLCPP,&skeleton_on_top,"key=O");
  606. rebar.TwAddVarRW("wireframe", TW_TYPE_BOOLCPP,&wireframe,"key=l");
  607. rebar.load(REBAR_NAME);
  608. // Init antweakbar
  609. glutInitDisplayString( "rgba depth double samples>=8 ");
  610. glutInitWindowSize(glutGet(GLUT_SCREEN_WIDTH)/2.0,glutGet(GLUT_SCREEN_HEIGHT)/2.0);
  611. glutCreateWindow("upright");
  612. glutDisplayFunc(display);
  613. glutReshapeFunc(reshape);
  614. glutKeyboardFunc(key);
  615. glutMouseFunc(mouse);
  616. glutMotionFunc(mouse_drag);
  617. glutPassiveMotionFunc((GLUTmousemotionfun)TwEventMouseMotionGLUT);
  618. glutMainLoop();
  619. return 0;
  620. }