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
45 #if defined(FX) && defined(XMESA)
46 # include <GL/xmesa.h>
57 # include <shellapi.h>
59 # include <sys/cygwin.h>
63 #include <simgear/constants.h>
64 #include <simgear/debug/logstream.hxx>
65 #include <simgear/misc/sg_path.hxx>
66 #include <simgear/screen/screen-dump.hxx>
68 #include <Include/general.hxx>
69 #include <Aircraft/aircraft.hxx>
70 #include <Airports/simple.hxx>
71 #include <Autopilot/auto_gui.hxx>
72 #include <Autopilot/newauto.hxx>
73 #include <Cockpit/panel.hxx>
74 #include <Controls/controls.hxx>
75 #include <FDM/flight.hxx>
76 #include <Main/fg_init.hxx>
77 #include <Main/fg_io.hxx>
78 #include <Main/globals.hxx>
79 #include <Main/fg_props.hxx>
80 #include <Main/viewmgr.hxx>
83 #include <NetworkOLK/network.h>
86 #if defined( WIN32 ) && !defined( __CYGWIN__ ) && !defined(__MINGW32__)
87 # include <simgear/screen/win32-printer.h>
88 # include <simgear/screen/GlBitmaps.h>
92 #include "gui_local.hxx"
93 #include "net_dlg.hxx"
94 #include "preset_dlg.hxx"
95 #include "prop_picker.hxx"
96 #include "sgVec3Slider.hxx"
100 #ifndef SG_HAVE_NATIVE_SGI_COMPILERS
104 // main.cxx hack, should come from an include someplace
105 extern void fgInitVisuals( void );
106 extern void fgReshape( int width, int height );
107 extern void fgRenderFrame( void );
109 extern void fgHUDalphaAdjust( puObject * );
112 extern void fgLatLonFormatToggle( puObject *);
114 #ifdef FG_NETWORK_OLK
115 extern void net_fgd_scan(puObject *cb);
116 #endif // #ifdef FG_NETWORK_OLK
118 #if defined( TR_HIRES_SNAP)
119 #include <simgear/screen/tr.h>
120 extern void trRenderFrame( void );
121 extern void fgUpdateHUD( GLfloat x_start, GLfloat y_start,
122 GLfloat x_end, GLfloat y_end );
125 extern puMenuBar *mainMenuBar;
127 puDialogBox *dialogBox = 0;
128 puFrame *dialogFrame = 0;
129 puText *dialogBoxMessage = 0;
130 puOneShot *dialogBoxOkButton = 0;
132 puDialogBox *YNdialogBox = 0;
133 puFrame *YNdialogFrame = 0;
134 puText *YNdialogBoxMessage = 0;
135 puOneShot *YNdialogBoxOkButton = 0;
136 puOneShot *YNdialogBoxNoButton = 0;
138 char *gui_msg_OK; // "OK"
139 char *gui_msg_NO; // "NO"
140 char *gui_msg_YES; // "YES"
141 char *gui_msg_CANCEL; // "CANCEL"
142 char *gui_msg_RESET; // "RESET"
144 char msg_OK[] = "OK";
145 char msg_NO[] = "NO";
146 char msg_YES[] = "YES";
147 char msg_CANCEL[] = "Cancel";
148 char msg_RESET[] = "Reset";
150 char global_dialog_string[256];
152 const __fg_gui_fn_t __fg_gui_fn[] = {
155 {"saveFlight", saveFlight},
156 {"loadFlight", loadFlight},
159 {"dumpHiResSnapShot", dumpHiResSnapShot},
161 {"dumpSnapShot", dumpSnapShot},
162 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
163 {"printScreen", printScreen},
165 {"MayBeGoodBye", MayBeGoodBye},
168 {"guiTogglePanel", guiTogglePanel},
169 {"PilotOffsetAdjust", PilotOffsetAdjust},
170 {"fgHUDalphaAdjust", fgHUDalphaAdjust},
171 {"prop_pickerView", prop_pickerView},
174 {"fgPresetAirport", fgPresetAirport},
175 {"fgPresetRunway", fgPresetRunway},
176 {"fgPresetOffsetDistance", fgPresetOffsetDistance},
177 {"fgPresetAltitude", fgPresetAltitude},
178 {"fgPresetGlideslope", fgPresetGlideslope},
179 {"fgPresetAirspeed", fgPresetAirspeed},
180 {"fgPresetCommit", fgPresetCommit},
183 #ifdef FG_NETWORK_OLK
184 {"net_display_toggle", net_display_toggle},
185 {"NewCallSign", NewCallSign},
186 {"net_fgd_scan", net_fgd_scan},
187 {"net_register", net_register},
188 {"net_unregister", net_unregister},
192 {"NewAltitude", NewAltitude},
193 {"NewHeading", NewHeading},
194 {"AddWayPoint", AddWayPoint},
195 {"PopWayPoint", PopWayPoint},
196 {"ClearRoute", ClearRoute},
197 {"fgAPAdjust", fgAPAdjust},
198 {"fgLatLonFormatToggle", fgLatLonFormatToggle},
203 // Structure termination
208 /* ================ General Purpose Functions ================ */
210 void initDialog(void) {
211 // Initialize our GLOBAL GUI STRINGS
212 gui_msg_OK = msg_OK; // "OK"
213 gui_msg_NO = msg_NO; // "NO"
214 gui_msg_YES = msg_YES; // "YES"
215 gui_msg_CANCEL = msg_CANCEL; // "CANCEL"
216 gui_msg_RESET = msg_RESET; // "RESET"
219 // General Purpose Message Box
220 void mkDialog (const char *txt)
222 strncpy(global_dialog_string, txt, 256);
223 dialogBoxMessage->setLabel(global_dialog_string);
224 FG_PUSH_PUI_DIALOG( dialogBox );
227 // Message Box to report an error.
228 void guiErrorMessage (const char *txt)
230 SG_LOG(SG_GENERAL, SG_ALERT, txt);
235 // Message Box to report a throwable (usually an exception).
236 void guiErrorMessage (const char *txt, const sg_throwable &throwable)
240 msg += throwable.getFormattedMessage();
241 if (!throwable.getOrigin().empty()) {
242 msg += "\n (reported by ";
243 msg += throwable.getOrigin();
246 SG_LOG(SG_GENERAL, SG_ALERT, msg);
248 mkDialog(msg.c_str());
251 // Toggle the Menu and Mouse display state
252 void guiToggleMenu(void)
255 // printf("Hiding Menu\n");
256 mainMenuBar->hide ();
257 #if defined(WIN32_CURSOR_TWEAKS_OFF)
258 if( mouse_mode == MOUSE_POINTER )
260 #endif // WIN32_CURSOR_TWEAKS_OFF
262 // printf("Showing Menu\n");
263 mainMenuBar->reveal();
268 gui_menu_on = ~gui_menu_on;
271 // Intercept the Escape Key
272 void ConfirmExitDialog(void)
274 FG_PUSH_PUI_DIALOG( YNdialogBox );
279 /* -----------------------------------------------------------------------
280 the Gui callback functions
281 ____________________________________________________________________*/
284 // Hier Neu :-) This is my newly added code
285 // Added by David Findlay <nedz@bigpond.com>
286 // on Sunday 3rd of December
288 // Start new Save Dialog Box
289 puDialogBox *SaveDialog = 0;
290 puFrame *SaveDialogFrame = 0;
291 puText *SaveDialogMessage = 0;
292 puInput *SaveDialogInput = 0;
294 puOneShot *SaveDialogOkButton = 0;
295 puOneShot *SaveDialogCancelButton = 0;
296 // static puOneShot *SaveDialogResetButton = 0;
298 // Default save filename
299 char saveFile[256] = "fgfs.sav";
302 void SaveDialogCancel(puObject *) {
303 FG_POP_PUI_DIALOG( SaveDialog );
306 // If press OK do this
307 void SaveDialogOk(puObject*) {
309 FG_POP_PUI_DIALOG( SaveDialog );
312 SaveDialogInput->getValue(&s);
315 cout << saveFile << endl;
316 if (output.good() && fgSaveFlight(output)) {
318 mkDialog("Saved flight");
319 SG_LOG(SG_INPUT, SG_INFO, "Saved flight");
321 mkDialog("Cannot save flight");
322 SG_LOG(SG_INPUT, SG_ALERT, "Cannot save flight");
327 void saveFlight(puObject *cv) {
328 SaveDialog = new puDialogBox (150, 50);
330 SaveDialogFrame = new puFrame (0,0,350, 150);
332 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
333 SaveDialogMessage -> setLabel ("File Name:");
335 SaveDialogInput = new puInput (50, 70, 300, 100);
336 SaveDialogInput -> setValue (saveFile);
337 SaveDialogInput -> acceptInput();
339 SaveDialogOkButton = new puOneShot (50, 10, 110, 50);
340 SaveDialogOkButton -> setLegend (gui_msg_OK);
341 SaveDialogOkButton -> setCallback ( SaveDialogOk );
342 SaveDialogOkButton -> makeReturnDefault(TRUE);
344 SaveDialogCancelButton = new puOneShot (140, 10, 210, 50);
345 SaveDialogCancelButton -> setLegend (gui_msg_CANCEL);
346 SaveDialogCancelButton -> setCallback ( SaveDialogCancel );
348 FG_FINALIZE_PUI_DIALOG( SaveDialog );
350 SaveDialog -> reveal();
354 puDialogBox *LoadDialog = 0;
355 puFrame *LoadDialogFrame = 0;
356 puText *LoadDialogMessage = 0;
357 puInput *LoadDialogInput = 0;
359 puOneShot *LoadDialogOkButton = 0;
360 puOneShot *LoadDialogCancelButton = 0;
361 // static puOneShot *LoadDialogResetButton = 0;
363 // Default load filename
364 char loadFile[256] = "fgfs.sav";
366 // Do this if the person click okay
367 void LoadDialogOk(puObject *) {
369 FG_POP_PUI_DIALOG( LoadDialog );
372 LoadDialogInput->getValue(&l);
375 if (input.good() && fgLoadFlight(input)) {
377 mkDialog("Loaded flight");
378 SG_LOG(SG_INPUT, SG_INFO, "Restored flight");
380 mkDialog("Failed to load flight");
381 SG_LOG(SG_INPUT, SG_ALERT, "Cannot load flight");
385 // Do this if the person presses cancel
386 void LoadDialogCancel(puObject *) {
387 FG_POP_PUI_DIALOG( LoadDialog );
390 // Create Load Dialog
391 void loadFlight(puObject *cb)
393 LoadDialog = new puDialogBox (150, 50);
395 LoadDialogFrame = new puFrame (0,0,350, 150);
397 = new puText( (150 - puGetDefaultLabelFont().getStringWidth( "File Name:" ) / 2), 110 );
398 LoadDialogMessage -> setLabel ("File Name:");
400 LoadDialogInput = new puInput (50, 70, 300, 100);
401 LoadDialogInput -> setValue (loadFile);
402 LoadDialogInput -> acceptInput();
404 LoadDialogOkButton = new puOneShot (50, 10, 110, 50);
405 LoadDialogOkButton -> setLegend (gui_msg_OK);
406 LoadDialogOkButton -> setCallback ( LoadDialogOk );
407 LoadDialogOkButton -> makeReturnDefault(TRUE);
409 LoadDialogCancelButton = new puOneShot (140, 10, 210, 50);
410 LoadDialogCancelButton -> setLegend (gui_msg_CANCEL);
411 LoadDialogCancelButton -> setCallback ( LoadDialogCancel );
413 FG_FINALIZE_PUI_DIALOG( LoadDialog );
415 LoadDialog -> reveal();
418 // This is the accessor function
419 void guiTogglePanel(puObject *cb)
421 if (fgGetBool("/sim/panel/visibility"))
422 fgSetBool("/sim/panel/visibility", false);
424 fgSetBool("/sim/panel/visibility", true);
426 fgReshape(fgGetInt("/sim/startup/xsize"),
427 fgGetInt("/sim/startup/ysize"));
430 //void MenuHideMenuCb(puObject *cb)
431 void hideMenuCb (puObject *cb)
436 void goodBye(puObject *)
438 // SG_LOG( SG_INPUT, SG_ALERT,
439 // "Program exiting normally at user request." );
440 cout << "Program exiting normally at user request." << endl;
442 #ifdef FG_NETWORK_OLK
443 if ( fgGetBool("/sim/networking/network-olk") ) {
444 if ( net_is_registered == 0 ) fgd_send_com( "8", FGFS_host);
448 // close all external I/O connections
449 globals->get_io()->shutdown_all();
455 void goAwayCb (puObject *me)
457 FG_POP_PUI_DIALOG( dialogBox );
460 void mkDialogInit (void)
462 // printf("mkDialogInit\n");
463 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
464 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
465 dialogBox = new puDialogBox (x, y); // 150, 50
467 dialogFrame = new puFrame (0,0,400,100);
468 dialogBoxMessage = new puText (10, 70);
469 dialogBoxMessage -> setLabel ("");
470 dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
471 dialogBoxOkButton -> setLegend (gui_msg_OK);
472 dialogBoxOkButton -> makeReturnDefault (TRUE );
473 dialogBoxOkButton -> setCallback (goAwayCb);
475 FG_FINALIZE_PUI_DIALOG( dialogBox );
478 void MayBeGoodBye(puObject *)
483 void goAwayYesNoCb(puObject *me)
485 FG_POP_PUI_DIALOG( YNdialogBox);
488 void ConfirmExitDialogInit(void)
490 char msg[] = "Really Quit";
493 // printf("ConfirmExitDialogInit\n");
494 int len = 200 - puGetDefaultLabelFont().getStringWidth ( msg ) / 2;
496 int x = (fgGetInt("/sim/startup/xsize")/2 - 400/2);
497 int y = (fgGetInt("/sim/startup/ysize")/2 - 100/2);
499 YNdialogBox = new puDialogBox (x, y); // 150, 50
501 YNdialogFrame = new puFrame (0,0,400, 100);
503 YNdialogBoxMessage = new puText (len, 70);
504 YNdialogBoxMessage -> setDefaultValue (msg);
505 YNdialogBoxMessage -> getDefaultValue (&s);
506 YNdialogBoxMessage -> setLabel (s);
508 YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
509 YNdialogBoxOkButton -> setLegend (gui_msg_OK);
510 YNdialogBoxOkButton -> makeReturnDefault (TRUE );
511 YNdialogBoxOkButton -> setCallback (goodBye);
513 YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
514 YNdialogBoxNoButton -> setLegend (gui_msg_NO);
515 YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
517 FG_FINALIZE_PUI_DIALOG( YNdialogBox );
520 void notCb (puObject *)
522 mkDialog ("This function isn't implemented yet");
525 void helpCb (puObject *)
529 #if defined(FX) && !defined(WIN32)
530 # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
531 if ( globals->get_fullscreen() ) {
532 globals->set_fullscreen(false);
533 XMesaSetFXmode( XMESA_FX_WINDOW );
538 SGPath path( globals->get_fg_root() );
539 path.append( "Docs/index.html" );
543 string help_app = fgGetString("/sim/startup/browser-app");
545 if ( system("xwininfo -name Netscape > /dev/null 2>&1") == 0 ) {
546 command = help_app + " -remote \"openURL(" + path.str() + ")\"";
548 command = help_app + " " + path.str();
551 system( command.c_str() );
555 // Look for favorite browser
556 char Dummy[1024], ExecName[1024], browserParameter[1024];
557 char win32_name[1024];
559 cygwin32_conv_to_full_win32_path(path.c_str(),win32_name);
561 strcpy(win32_name,path.c_str());
564 FindExecutable(win32_name, Dummy, ExecName);
565 sprintf(browserParameter, "file:///%s", win32_name);
566 ShellExecute ( NULL, "open", ExecName, browserParameter, Dummy,
571 mkDialog ("Help started in your web browser window.");
574 #if defined( TR_HIRES_SNAP)
579 bool show_pu_cursor = false;
580 bool show_menu = false;
581 char *filename = new char [24];
582 static int count = 1;
584 static const SGPropertyNode *master_freeze
585 = fgGetNode("/sim/freeze/master");
587 bool freeze = master_freeze->getBoolValue();
589 fgSetBool("/sim/freeze/master", true);
597 if ( !puCursorIsHidden() ) {
598 show_pu_cursor = true;
603 fgReshape( fgGetInt("/sim/startup/xsize"),
604 fgGetInt("/sim/startup/ysize") );
606 // we need two render frames here to clear the menu and cursor
607 // ... not sure why but doing an extra fgRenderFrame() shouldn't
612 // Make sure we have SSG projection primed for current view
613 glMatrixMode(GL_MODELVIEW);
615 ssgSetCamera( (sgVec4 *)globals->get_current_view()->get_VIEW() );
616 ssgSetFOV( globals->get_current_view()->get_h_fov(),
617 globals->get_current_view()->get_v_fov() );
618 // ssgSetNearFar( 10.0f, 120000.0f );
619 ssgSetNearFar( 0.5f, 1200000.0f );
622 // This ImageSize stuff is a temporary hack
623 // should probably use 128x128 tile size and
624 // support any image size
626 // This should be a requester to get multiplier from user
628 int width = fgGetInt("/sim/startup/xsize");
629 int height = fgGetInt("/sim/startup/ysize");
631 /* allocate buffer large enough to store one tile */
632 GLubyte *tile = (GLubyte *)malloc(width * height * 3 * sizeof(GLubyte));
634 printf("Malloc of tile buffer failed!\n");
638 int imageWidth = multiplier*width;
639 int imageHeight = multiplier*height;
641 /* allocate buffer to hold a row of tiles */
643 = (GLubyte *)malloc(imageWidth * height * 3 * sizeof(GLubyte));
646 printf("Malloc of tile row buffer failed!\n");
649 TRcontext *tr = trNew();
650 trTileSize(tr, width, height, 0);
651 trTileBuffer(tr, GL_RGB, GL_UNSIGNED_BYTE, tile);
652 trImageSize(tr, imageWidth, imageHeight);
653 trRowOrder(tr, TR_TOP_TO_BOTTOM);
654 sgFrustum *frustum = ssgGetFrustum();
656 frustum->getLeft(), frustum->getRight(),
657 frustum->getBot(), frustum->getTop(),
658 frustum->getNear(), frustum->getFar());
660 /* Prepare ppm output file */
661 while (count < 1000) {
662 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
663 if ( (f = fopen(filename, "r")) == NULL )
667 f = fopen(filename, "wb");
669 printf("Couldn't open image file: %s\n", filename);
675 fprintf(f,"# ppm-file created by %s\n", "trdemo2");
676 fprintf(f,"%i %i\n", imageWidth, imageHeight);
679 /* just to be safe... */
680 glPixelStorei(GL_PACK_ALIGNMENT, 1);
682 /* Because the HUD and Panel change the ViewPort we will
683 * need to handle some lowlevel stuff ourselves */
684 int ncols = trGet(tr, TR_COLUMNS);
685 int nrows = trGet(tr, TR_ROWS);
687 bool do_hud = fgGetBool("/sim/hud/visibility");
688 GLfloat hud_col_step = 640.0 / ncols;
689 GLfloat hud_row_step = 480.0 / nrows;
691 bool do_panel = fgPanelVisible();
692 GLfloat panel_col_step = current_panel->getWidth() / ncols;
693 GLfloat panel_row_step = current_panel->getHeight() / nrows;
699 int curColumn = trGet(tr, TR_CURRENT_COLUMN);
700 int curRow = trGet(tr, TR_CURRENT_ROW);
703 fgUpdateHUD( curColumn*hud_col_step, curRow*hud_row_step,
704 (curColumn+1)*hud_col_step, (curRow+1)*hud_row_step );
706 current_panel->update( curColumn*panel_col_step, panel_col_step,
707 curRow*panel_row_step, panel_row_step );
708 more = trEndTile(tr);
710 /* save tile into tile row buffer*/
711 int curTileWidth = trGet(tr, TR_CURRENT_TILE_WIDTH);
712 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
713 int bytesPerTileRow = (width) * 3*sizeof(GLubyte);
714 int xOffset = curColumn * bytesPerTileRow;
715 int bytesPerCurrentTileRow = (curTileWidth) * 3*sizeof(GLubyte);
717 for (i=0;i<height;i++) {
718 memcpy(buffer + i*bytesPerImageRow + xOffset, /* Dest */
719 tile + i*bytesPerTileRow, /* Src */
720 bytesPerCurrentTileRow); /* Byte count*/
723 if (curColumn == trGet(tr, TR_COLUMNS)-1) {
724 /* write this buffered row of tiles to the file */
725 int curTileHeight = trGet(tr, TR_CURRENT_TILE_HEIGHT);
726 int bytesPerImageRow = imageWidth * 3*sizeof(GLubyte);
728 for (i=0;i<curTileHeight;i++) {
729 /* Remember, OpenGL images are bottom to top. Have to reverse. */
730 GLubyte *rowPtr = buffer + (curTileHeight-1-i) * bytesPerImageRow;
731 fwrite(rowPtr, 1, imageWidth*3, f);
737 fgReshape( width, height );
743 message = "Snap shot saved to ";
745 mkDialog (message.c_str());
750 // message = "Snap shot saved to ";
751 // message += filename;
752 // mkDialog (message.c_str());
759 if ( show_pu_cursor ) {
764 fgSetBool("/sim/freeze/master", false);
767 #endif // #if defined( TR_HIRES_SNAP)
770 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
772 void rotateView( double roll, double pitch, double yaw )
778 GLubyte *hiResScreenCapture( int multiplier )
780 float oldfov = fgGetDouble("/sim/current-view/field-of-view");
781 float fov = oldfov / multiplier;
782 FGViewer *v = globals->get_current_view();
783 fgSetDouble("/sim/current-view/field-of-view", fov);
785 int cur_width = fgGetInt("/sim/startup/xsize");
786 int cur_height = fgGetInt("/sim/startup/ysize");
787 if (b1) delete( b1 );
788 // New empty (mostly) bitmap
789 b1 = new GlBitmap( GL_RGB, 1, 1, (unsigned char *)"123" );
791 for ( y = 0; y < multiplier; y++ ) {
792 for ( x = 0; x < multiplier; x++ ) {
793 fgReshape( cur_width, cur_height );
795 rotateView( 0, (y*fov)-((multiplier-1)*fov/2), (x*fov)-((multiplier-1)*fov/2) );
799 b1->copyBitmap( &b2, cur_width*x, cur_height*y );
802 fgSetDouble("/sim/current-view/field-of-view", oldfov);
803 return b1->getBitmap();
807 #if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
808 // win32 print screen function
809 void printScreen ( puObject *obj ) {
810 bool show_pu_cursor = false;
812 if ( !puCursorIsHidden() ) {
813 show_pu_cursor = true;
819 CGlPrinter p( CGlPrinter::PRINT_BITMAP );
820 int cur_width = fgGetInt("/sim/startup/xsize");
821 int cur_height = fgGetInt("/sim/startup/ysize");
822 p.Begin( "FlightGear", cur_width*3, cur_height*3 );
823 p.End( hiResScreenCapture(3) );
826 mainMenuBar->reveal();
829 if ( show_pu_cursor ) {
834 #endif // #ifdef WIN32
837 void dumpSnapShot ( puObject *obj ) {
842 void dumpHiResSnapShot ( puObject *obj ) {
847 // do a screen snap shot
848 void fgDumpSnapShot () {
849 bool show_pu_cursor = false;
850 char *filename = new char [24];
852 static int count = 1;
854 static const SGPropertyNode *master_freeze
855 = fgGetNode("/sim/freeze/master");
857 bool freeze = master_freeze->getBoolValue();
859 fgSetBool("/sim/freeze/master", true);
864 if ( !puCursorIsHidden() ) {
865 show_pu_cursor = true;
870 fgReshape( fgGetInt("/sim/startup/xsize"),
871 fgGetInt("/sim/startup/ysize") );
873 // we need two render frames here to clear the menu and cursor
874 // ... not sure why but doing an extra fgRenderFrame() shouldn't
879 while (count < 1000) {
881 snprintf(filename, 24, "fgfs-screen-%03d.ppm", count++);
882 if ( (fp = fopen(filename, "r")) == NULL )
887 if ( sg_glDumpWindow( filename,
888 fgGetInt("/sim/startup/xsize"),
889 fgGetInt("/sim/startup/ysize")) ) {
890 message = "Snap shot saved to ";
893 message = "Failed to save to ";
897 mkDialog (message.c_str());
901 if ( show_pu_cursor ) {
907 mainMenuBar->reveal();
911 fgSetBool("/sim/freeze/master", false);
915 #ifdef FG_NETWORK_OLK
916 void net_display_toggle( puObject *cb)
918 net_hud_display = (net_hud_display) ? 0 : 1;
919 printf("Toggle net_hud_display : %d\n", net_hud_display);
922 void net_register( puObject *cb)
924 fgd_send_com( "1", FGFS_host );
925 net_is_registered = 0;
926 printf("Registering to deamon\n");
929 void net_unregister( puObject *cb)
931 fgd_send_com( "8", FGFS_host );
932 net_is_registered = -1;
933 printf("Unregistering from deamon\n");
936 #endif // #ifdef FG_NETWORK_OLK