1 /**************************************************************************
4 * Based on gui.cxx and renamed on 2002/08/13 by Erik Hofman.
6 * Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
9 * Additional mouse supported added by David Megginson, 1999.
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of the
14 * License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 **************************************************************************/
33 #include <simgear/compiler.h>
35 #ifdef SG_MATH_EXCEPTION_CLASH
46 #if defined(FX) && defined(XMESA)
47 # include <GL/xmesa.h>
58 # include <shellapi.h>
60 # include <sys/cygwin.h>
64 #include <simgear/constants.h>
65 #include <simgear/debug/logstream.hxx>
66 #include <simgear/misc/sg_path.hxx>
67 #include <simgear/screen/screen-dump.hxx>
69 #include <Include/general.hxx>
70 #include <Aircraft/aircraft.hxx>
71 #include <Airports/simple.hxx>
72 #include <Autopilot/auto_gui.hxx>
73 #include <Autopilot/newauto.hxx>
74 #include <Cockpit/panel.hxx>
75 #include <Controls/controls.hxx>
76 #include <FDM/flight.hxx>
77 #include <Main/fg_init.hxx>
78 #include <Main/fg_io.hxx>
79 #include <Main/globals.hxx>
80 #include <Main/fg_props.hxx>
81 #include <Main/viewmgr.hxx>
84 #include <NetworkOLK/network.h>
87 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
88 # include <simgear/screen/win32-printer.h>
89 # include <simgear/screen/GlBitmaps.h>
93 #include "gui_local.hxx"
94 #include "apt_dlg.hxx"
95 #include "net_dlg.hxx"
96 #include "sgVec3Slider.hxx"
97 #include "prop_picker.hxx"
101 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
105 // main.cxx hack, should come from an include someplace
106 extern void fgInitVisuals( void );
107 extern void fgReshape( int width, int height );
108 extern void fgRenderFrame( void );
110 extern FGInterface cur_view_fdm;
111 extern void fgHUDalphaAdjust( puObject * );
114 extern void fgLatLonFormatToggle( puObject *);
116 #ifdef FG_NETWORK_OLK
117 extern void net_fgd_scan(puObject *cb);
118 #endif // #ifdef FG_NETWORK_OLK
120 #if defined( TR_HIRES_SNAP)
121 #include <simgear/screen/tr.h>
122 extern void trRenderFrame( void );
123 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
124 GLfloat x_end, GLfloat y_end );
127 extern puMenuBar *mainMenuBar;
129 puDialogBox *dialogBox = 0;
130 puFrame *dialogFrame = 0;
131 puText *dialogBoxMessage = 0;
132 puOneShot *dialogBoxOkButton = 0;
134 puDialogBox *YNdialogBox = 0;
135 puFrame *YNdialogFrame = 0;
136 puText *YNdialogBoxMessage = 0;
137 puOneShot *YNdialogBoxOkButton = 0;
138 puOneShot *YNdialogBoxNoButton = 0;
140 char *gui_msg_OK; // "OK"
141 char *gui_msg_NO; // "NO"
142 char *gui_msg_YES; // "YES"
143 char *gui_msg_CANCEL; // "CANCEL"
144 char *gui_msg_RESET; // "RESET"
146 char msg_OK[] = "OK";
147 char msg_NO[] = "NO";
148 char msg_YES[] = "YES";
149 char msg_CANCEL[] = "Cancel";
150 char msg_RESET[] = "Reset";
152 char global_dialog_string[256];
154 const __fg_gui_fn_t __fg_gui_fn[] = {
157 {"saveFlight", saveFlight},
158 {"loadFlight", loadFlight},
161 {"dumpHiResSnapShot", dumpHiResSnapShot},
163 {"dumpSnapShot", dumpSnapShot},
164 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
165 {"printScreen", printScreen},
167 {"MayBeGoodBye", MayBeGoodBye},
170 {"guiTogglePanel", guiTogglePanel},
171 {"PilotOffsetAdjust", PilotOffsetAdjust},
172 {"fgHUDalphaAdjust", fgHUDalphaAdjust},
173 {"prop_pickerView", prop_pickerView},
176 {"NewAirport", NewAirport},
179 #ifdef FG_NETWORK_OLK
180 {"net_display_toggle", net_display_toggle},
181 {"NewCallSign", NewCallSign},
182 {"net_fgd_scan", net_fgd_scan},
183 {"net_register", net_register},
184 {"net_unregister", net_unregister},
188 {"NewAltitude", NewAltitude},
189 {"AddWayPoint", AddWayPoint},
190 {"PopWayPoint", PopWayPoint},
191 {"ClearRoute", ClearRoute},
192 {"fgAPAdjust", fgAPAdjust},
193 {"fgLatLonFormatToggle", fgLatLonFormatToggle},
198 // Structure termination
203 /* ================ General Purpose Functions ================ */
205 void initDialog(void) {
206 // Initialize our GLOBAL GUI STRINGS
207 gui_msg_OK = msg_OK; // "OK"
208 gui_msg_NO = msg_NO; // "NO"
209 gui_msg_YES = msg_YES; // "YES"
210 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
211 gui_msg_RESET = msg_RESET; // "RESET"
214 // General Purpose Message Box
215 void mkDialog (const char *txt)
217 strncpy(global_dialog_string, txt, 256);
218 dialogBoxMessage->setLabel(global_dialog_string);
219 FG_PUSH_PUI_DIALOG( dialogBox );
222 // Message Box to report an error.
223 void guiErrorMessage (const char *txt)
225 SG_LOG(SG_GENERAL, SG_ALERT, txt);
230 // Message Box to report a throwable (usually an exception).
231 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
235 msg += throwable.getFormattedMessage();
236 if (!throwable.getOrigin().empty()) {
237 msg += "\n (reported by ";
238 msg += throwable.getOrigin();
241 SG_LOG(SG_GENERAL, SG_ALERT, msg);
243 mkDialog(msg.c_str());
246 // Toggle the Menu and Mouse display state
247 void guiToggleMenu(void)
250 // printf("Hiding Menu\n");
251 mainMenuBar->hide ();
252 #if defined(WIN32_CURSOR_TWEAKS_OFF)
253 if( mouse_mode == MOUSE_POINTER )
255 #endif // WIN32_CURSOR_TWEAKS_OFF
257 // printf("Showing Menu\n");
258 mainMenuBar->reveal();
263 gui_menu_on = ~gui_menu_on;
266 // Intercept the Escape Key
267 void ConfirmExitDialog(void)
269 FG_PUSH_PUI_DIALOG( YNdialogBox );
274 /* -----------------------------------------------------------------------
275 the Gui callback functions
276 ____________________________________________________________________*/
279 // Hier Neu :-) This is my newly added code
280 // Added by David Findlay <nedz@bigpond.com>
281 // on Sunday 3rd of December
283 // Start new Save Dialog Box
284 puDialogBox *SaveDialog = 0;
285 puFrame *SaveDialogFrame = 0;
286 puText *SaveDialogMessage = 0;
287 puInput *SaveDialogInput = 0;
289 puOneShot *SaveDialogOkButton = 0;
290 puOneShot *SaveDialogCancelButton = 0;
291 // static puOneShot *SaveDialogResetButton = 0;
293 // Default save filename
294 char saveFile[256] = "fgfs.sav";
297 void SaveDialogCancel(puObject *) {
298 FG_POP_PUI_DIALOG( SaveDialog );
301 // If press OK do this
302 void SaveDialogOk(puObject*) {
304 FG_POP_PUI_DIALOG( SaveDialog );
307 SaveDialogInput->getValue(&s);
310 cout << saveFile << endl;
311 if (output.good() && fgSaveFlight(output)) {
313 mkDialog("Saved flight");
314 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
316 mkDialog("Cannot save flight");
317 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
322 void saveFlight(puObject *cv) {
323 SaveDialog = new puDialogBox (150, 50);
325 SaveDialogFrame = new puFrame (0,0,350, 150);
327 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
328 SaveDialogMessage -> setLabel ("File Name:");
330 SaveDialogInput = new puInput (50, 70, 300, 100);
331 SaveDialogInput -> setValue (saveFile);
332 SaveDialogInput -> acceptInput();
334 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
335 SaveDialogOkButton -> setLegend (gui_msg_OK);
336 SaveDialogOkButton -> setCallback ( SaveDialogOk );
337 SaveDialogOkButton -> makeReturnDefault(TRUE);
339 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
340 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
341 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
343 FG_FINALIZE_PUI_DIALOG( SaveDialog );
345 SaveDialog -> reveal();
349 puDialogBox *LoadDialog = 0;
350 puFrame *LoadDialogFrame = 0;
351 puText *LoadDialogMessage = 0;
352 puInput *LoadDialogInput = 0;
354 puOneShot *LoadDialogOkButton = 0;
355 puOneShot *LoadDialogCancelButton = 0;
356 // static puOneShot *LoadDialogResetButton = 0;
358 // Default load filename
359 char loadFile[256] = "fgfs.sav";
361 // Do this if the person click okay
362 void LoadDialogOk(puObject *) {
364 FG_POP_PUI_DIALOG( LoadDialog );
367 LoadDialogInput->getValue(&l);
370 if (input.good() && fgLoadFlight(input)) {
372 mkDialog("Loaded flight");
373 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
375 mkDialog("Failed to load flight");
376 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
380 // Do this if the person presses cancel
381 void LoadDialogCancel(puObject *) {
382 FG_POP_PUI_DIALOG( LoadDialog );
385 // Create Load Dialog
386 void loadFlight(puObject *cb)
388 LoadDialog = new puDialogBox (150, 50);
390 LoadDialogFrame = new puFrame (0,0,350, 150);
392 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
393 LoadDialogMessage -> setLabel ("File Name:");
395 LoadDialogInput = new puInput (50, 70, 300, 100);
396 LoadDialogInput -> setValue (loadFile);
397 LoadDialogInput -> acceptInput();
399 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
400 LoadDialogOkButton -> setLegend (gui_msg_OK);
401 LoadDialogOkButton -> setCallback ( LoadDialogOk );
402 LoadDialogOkButton -> makeReturnDefault(TRUE);
404 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
405 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
406 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
408 FG_FINALIZE_PUI_DIALOG( LoadDialog );
410 LoadDialog -> reveal();
413 // This is the accessor function
414 void guiTogglePanel(puObject *cb)
416 if (fgGetBool("/sim/panel/visibility"))
417 fgSetBool("/sim/panel/visibility", false);
419 fgSetBool("/sim/panel/visibility", true);
421 fgReshape(fgGetInt("/sim/startup/xsize"),
422 fgGetInt("/sim/startup/ysize"));
425 //void MenuHideMenuCb(puObject *cb)
426 void hideMenuCb (puObject *cb)
431 void goodBye(puObject *)
433 // SG_LOG( SG_INPUT, SG_ALERT,
434 // "Program exiting normally at user request." );
435 cout << "Program exiting normally at user request." << endl;
437 #ifdef FG_NETWORK_OLK
438 if ( fgGetBool("/sim/networking/network-olk") ) {
439 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
443 // close all external I/O connections
444 globals->get_io()->shutdown_all();
450 void goAwayCb (puObject *me)
452 FG_POP_PUI_DIALOG( dialogBox );
455 void mkDialogInit (void)
457 // printf("mkDialogInit\n");
458 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
459 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
460 dialogBox = new puDialogBox (x, y); // 150, 50
462 dialogFrame = new puFrame (0,0,400,100);
463 dialogBoxMessage = new puText (10, 70);
464 dialogBoxMessage -> setLabel ("");
465 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
466 dialogBoxOkButton -> setLegend (gui_msg_OK);
467 dialogBoxOkButton -> makeReturnDefault (TRUE );
468 dialogBoxOkButton -> setCallback (goAwayCb);
470 FG_FINALIZE_PUI_DIALOG( dialogBox );
473 void MayBeGoodBye(puObject *)
478 void goAwayYesNoCb(puObject *me)
480 FG_POP_PUI_DIALOG( YNdialogBox);
483 void ConfirmExitDialogInit(void)
485 char msg[] = "Really Quit";
488 // printf("ConfirmExitDialogInit\n");
489 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
491 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
492 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
494 YNdialogBox = new puDialogBox (x, y); // 150, 50
496 YNdialogFrame = new puFrame (0,0,400, 100);
498 YNdialogBoxMessage = new puText (len, 70);
499 YNdialogBoxMessage -> setDefaultValue (msg);
500 YNdialogBoxMessage -> getDefaultValue (&s);
501 YNdialogBoxMessage -> setLabel (s);
503 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
504 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
505 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
506 YNdialogBoxOkButton -> setCallback (goodBye);
508 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
509 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
510 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
512 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
515 void notCb (puObject *)
517 mkDialog ("This function isn't implemented yet");
520 void helpCb (puObject *)
524 #if defined(FX) && !defined(WIN32)
525 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
526 if ( globals->get_fullscreen() ) {
527 globals->set_fullscreen(false);
528 XMesaSetFXmode( XMESA_FX_WINDOW );
533 SGPath path( globals->get_fg_root() );
534 path.append( "Docs/index.html" );
538 string help_app = fgGetString("/sim/startup/browser-app");
540 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
541 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
543 command = help_app + " " + path.str();
546 system( command.c_str() );
550 // Look for favorite browser
551 char Dummy[1024], ExecName[1024], browserParameter[1024];
552 char win32_name[1024];
554 cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
556 strcpy(win32_name,path.c_str());
559 FindExecutable(win32_name, Dummy, ExecName);
560 sprintf(browserParameter, "file:///%s", win32_name);
561 ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
566 mkDialog ("Help started in your web browser window.");
569 #if defined( TR_HIRES_SNAP)
574 bool show_pu_cursor = false;
575 bool show_menu = false;
576 char *filename = new char [24];
577 static int count = 1;
579 static const SGPropertyNode *master_freeze
580 = fgGetNode("/sim/freeze/master");
582 bool freeze = master_freeze->getBoolValue();
584 fgSetBool("/sim/freeze/master", true);
592 if ( !puCursorIsHidden() ) {
593 show_pu_cursor = true;
598 fgReshape( fgGetInt("/sim/startup/xsize"),
599 fgGetInt("/sim/startup/ysize") );
601 // we need two render frames here to clear the menu and cursor
602 // ... not sure why but doing an extra fgRenderFrame() shouldn't
607 // Make sure we have SSG projection primed for current view
608 glMatrixMode(GL_MODELVIEW);
610 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
611 ssgSetFOV( globals->get_current_view()->get_h_fov(),
612 globals->get_current_view()->get_v_fov() );
613 // ssgSetNearFar( 10.0f, 120000.0f );
614 ssgSetNearFar( 0.5f, 1200000.0f );
617 // This ImageSize stuff is a temporary hack
618 // should probably use 128x128 tile size and
619 // support any image size
621 // This should be a requester to get multiplier from user
623 int width = fgGetInt("/sim/startup/xsize");
624 int height = fgGetInt("/sim/startup/ysize");
626 /* allocate buffer large enough to store one tile */
627 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
629 printf("Malloc of tile buffer failed!\n");
633 int imageWidth = multiplier*width;
634 int imageHeight = multiplier*height;
636 /* allocate buffer to hold a row of tiles */
638 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
641 printf("Malloc of tile row buffer failed!\n");
644 TRcontext *tr = trNew();
645 trTileSize(tr, width, height, 0);
646 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
647 trImageSize(tr, imageWidth, imageHeight);
648 trRowOrder(tr, TR_TOP_TO_BOTTOM);
649 sgFrustum *frustum = ssgGetFrustum();
651 frustum->getLeft(), frustum->getRight(),
652 frustum->getBot(), frustum->getTop(),
653 frustum->getNear(), frustum->getFar());
655 /* Prepare ppm output file */
656 while (count < 1000) {
657 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
658 if ( (f = fopen(filename, "r")) == NULL )
662 f = fopen(filename, "wb");
664 printf("Couldn't open image file: %s\n", filename);
670 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
671 fprintf(f,"%i %i\n", imageWidth, imageHeight);
674 /* just to be safe... */
675 glPixelStorei(GL_PACK_ALIGNMENT, 1);
677 /* Because the HUD and Panel change the ViewPort we will
678 * need to handle some lowlevel stuff ourselves */
679 int ncols = trGet(tr, TR_COLUMNS);
680 int nrows = trGet(tr, TR_ROWS);
682 bool do_hud = fgGetBool("/sim/hud/visibility");
683 GLfloat hud_col_step = 640.0 / ncols;
684 GLfloat hud_row_step = 480.0 / nrows;
686 bool do_panel = fgPanelVisible();
687 GLfloat panel_col_step = current_panel->getWidth() / ncols;
688 GLfloat panel_row_step = current_panel->getHeight() / nrows;
694 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
695 int curRow = trGet(tr, TR_CURRENT_ROW);
698 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
699 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
701 current_panel->update( curColumn*panel_col_step, panel_col_step,
702 curRow*panel_row_step, panel_row_step );
703 more = trEndTile(tr);
705 /* save tile into tile row buffer*/
706 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
707 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
708 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
709 int xOffset = curColumn * bytesPerTileRow;
710 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
712 for (i=0;i<height;i++) {
713 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
714 tile + i*bytesPerTileRow, /* Src */
715 bytesPerCurrentTileRow); /* Byte count*/
718 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
719 /* write this buffered row of tiles to the file */
720 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
721 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
723 for (i=0;i<curTileHeight;i++) {
724 /* Remember, OpenGL images are bottom to top. Have to reverse. */
725 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
726 fwrite(rowPtr, 1, imageWidth*3, f);
732 fgReshape( width, height );
738 message = "Snap shot saved to ";
740 mkDialog (message.c_str());
745 // message = "Snap shot saved to ";
746 // message += filename;
747 // mkDialog (message.c_str());
754 if ( show_pu_cursor ) {
759 fgSetBool("/sim/freeze/master", false);
762 #endif // #if defined( TR_HIRES_SNAP)
765 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
767 void rotateView( double roll, double pitch, double yaw )
773 GLubyte *hiResScreenCapture( int multiplier )
775 float oldfov = fgGetDouble("/sim/current-view/field-of-view");
776 float fov = oldfov / multiplier;
777 FGViewer *v = globals->get_current_view();
778 fgSetDouble("/sim/current-view/field-of-view", fov);
780 int cur_width = fgGetInt("/sim/startup/xsize");
781 int cur_height = fgGetInt("/sim/startup/ysize");
782 if (b1) delete( b1 );
783 // New empty (mostly) bitmap
784 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
786 for ( y = 0; y < multiplier; y++ ) {
787 for ( x = 0; x < multiplier; x++ ) {
788 fgReshape( cur_width, cur_height );
790 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
794 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
797 fgSetDouble("/sim/current-view/field-of-view", oldfov);
798 return b1->getBitmap();
802 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
803 // win32 print screen function
804 void printScreen ( puObject *obj ) {
805 bool show_pu_cursor = false;
807 if ( !puCursorIsHidden() ) {
808 show_pu_cursor = true;
814 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
815 int cur_width = fgGetInt("/sim/startup/xsize");
816 int cur_height = fgGetInt("/sim/startup/ysize");
817 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
818 p.End( hiResScreenCapture(3) );
821 mainMenuBar->reveal();
824 if ( show_pu_cursor ) {
829 #endif // #ifdef WIN32
832 void dumpSnapShot ( puObject *obj ) {
837 void dumpHiResSnapShot ( puObject *obj ) {
842 // do a screen snap shot
843 void fgDumpSnapShot () {
844 bool show_pu_cursor = false;
845 char *filename = new char [24];
847 static int count = 1;
849 static const SGPropertyNode *master_freeze
850 = fgGetNode("/sim/freeze/master");
852 bool freeze = master_freeze->getBoolValue();
854 fgSetBool("/sim/freeze/master", true);
859 if ( !puCursorIsHidden() ) {
860 show_pu_cursor = true;
865 fgReshape( fgGetInt("/sim/startup/xsize"),
866 fgGetInt("/sim/startup/ysize") );
868 // we need two render frames here to clear the menu and cursor
869 // ... not sure why but doing an extra fgRenderFrame() shouldn't
874 while (count < 1000) {
876 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
877 if ( (fp = fopen(filename, "r")) == NULL )
882 if ( sg_glDumpWindow( filename,
883 fgGetInt("/sim/startup/xsize"),
884 fgGetInt("/sim/startup/ysize")) ) {
885 message = "Snap shot saved to ";
888 message = "Failed to save to ";
892 mkDialog (message.c_str());
896 if ( show_pu_cursor ) {
902 mainMenuBar->reveal();
906 fgSetBool("/sim/freeze/master", false);
910 #ifdef FG_NETWORK_OLK
911 void net_display_toggle( puObject *cb)
913 net_hud_display = (net_hud_display) ? 0 : 1;
914 printf("Toggle net_hud_display : %d\n", net_hud_display);
917 void net_register( puObject *cb)
919 fgd_send_com( "1", FGFS_host );
920 net_is_registered = 0;
921 printf("Registering to deamon\n");
924 void net_unregister( puObject *cb)
926 fgd_send_com( "8", FGFS_host );
927 net_is_registered = -1;
928 printf("Unregistering from deamon\n");
931 #endif // #ifdef FG_NETWORK_OLK