20,741
edits
| Line 38: | Line 38: | ||
== Example: disabling PUI == | == Example: disabling PUI == | ||
{{Main article|Developing using CMake}} | |||
Knowing that [[PUI]] contains legacy OpenGL code and knowing it's scheduled to be removed anyway because it isn't compatible with modern OpenGL, we will disable it completely without | Knowing that [[PUI]] contains legacy OpenGL code and knowing it's scheduled to be removed anyway because it isn't compatible with modern OpenGL, we will disable it completely without | ||
| Line 66: | Line 67: | ||
So, after editing fg_init.cxx to prevent the PUI GUI from getting initialized by FlightGear, we will need to find remaining hard-coded references to it, to fix those up and deal with PUI not being available. This means grepping $FG_SRC for any references to <code>"pui"</code> to locate remaining get_subsystem() calls. (FIXME: new subsystem lookups use templates), this will include fgcommands (menu bindings) accessing the GUI. | So, after editing fg_init.cxx to prevent the PUI GUI from getting initialized by FlightGear, we will need to find remaining hard-coded references to it, to fix those up and deal with PUI not being available. This means grepping $FG_SRC for any references to <code>"pui"</code> to locate remaining get_subsystem() calls. (FIXME: new subsystem lookups use templates), this will include code in unrelated modules, e.g. fgcommands (think menu bindings) accessing the GUI via something like <code>get_subsystem("gui");</code> | ||
https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/src/Main/fg_scene_commands.cxx#l277 | |||
<syntaxhighlight lang="cpp"> | |||
NewGUI * gui = (NewGUI *)globals->get_subsystem("gui"); | |||
if (!gui) { | |||
return false; | |||
} | |||
</syntaxhighlight> | |||
Thus, it makes sense to intercept registration of these fgcommands at the bottom of the file by wrapping these inside ifdef macros: | |||
https://sourceforge.net/p/flightgear/flightgear/ci/next/tree/src/Main/fg_scene_commands.cxx#l497 | |||
<syntaxhighlight lang="cpp"> | |||
/** | |||
* Table of built-in commands. | |||
* | |||
* New commands do not have to be added here; any module in the application | |||
* can add a new command using globals->get_commands()->addCommand(...). | |||
*/ | |||
static struct { | |||
const char * name; | |||
SGCommandMgr::command_t command; | |||
} built_ins [] = { | |||
{ "exit", do_exit }, | |||
{ "reset", do_reset }, | |||
{ "reposition", do_reposition }, | |||
{ "switch-aircraft", do_switch_aircraft }, | |||
{ "panel-load", do_panel_load }, | |||
{ "preferences-load", do_preferences_load }, | |||
{ "toggle-fullscreen", do_toggle_fullscreen }, | |||
{ "screen-capture", do_screen_capture }, | |||
{ "hires-screen-capture", do_hires_screen_capture }, | |||
{ "tile-cache-reload", do_tile_cache_reload }, | |||
#if 0 | |||
{ "dialog-new", do_dialog_new }, | |||
{ "dialog-show", do_dialog_show }, | |||
{ "dialog-close", do_dialog_close }, | |||
{ "dialog-update", do_dialog_update }, | |||
{ "dialog-apply", do_dialog_apply }, | |||
{ "open-browser", do_open_browser }, | |||
{ "gui-redraw", do_gui_redraw }, | |||
#endif | |||
{ "add-model", do_add_model }, | |||
{ "presets-commit", do_presets_commit }, | |||
{ "press-cockpit-button", do_press_cockpit_button }, | |||
{ "release-cockpit-button", do_release_cockpit_button }, | |||
{ "dump-scenegraph", do_dump_scene_graph }, | |||
{ "dump-terrainbranch", do_dump_terrain_branch }, | |||
{ "print-visible-scene", do_print_visible_scene_info }, | |||
{ "reload-shaders", do_reload_shaders }, | |||
{ "reload-materials", do_materials_reload }, | |||
{ "open-launcher", do_open_launcher }, | |||
{ 0, 0 } // zero-terminated | |||
}; | |||
</syntaxhighlight> | |||
This will ensure that fgcommands that are PUI related won't be available in a non-PUI build. | |||
We should add separate build options to explicitly disable these features individually, e.g.: | We should add separate build options to explicitly disable these features individually, e.g.: | ||