[GTK3] Add "no-gl" CLI option

This commit is contained in:
Maximilian Mader 2020-05-05 21:38:56 +02:00
parent f46d35528b
commit f7beeb9c98
Signed by: Max
GPG Key ID: F71D56A3151C4FB3

View File

@ -49,6 +49,7 @@ typedef struct GuiData {
gchar *prefix; gchar *prefix;
gboolean fullscreen; gboolean fullscreen;
GB_model_t model; GB_model_t model;
gboolean force_software_renderer;
} cli_options; } cli_options;
GFile *file; GFile *file;
@ -332,10 +333,6 @@ static gint handle_local_options(GApplication *app, GVariantDict *options, gpoin
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (g_variant_dict_lookup(options, "fullscreen", "b", &count)) {
gui_data.cli_options.fullscreen = true;
}
// Handle model override // Handle model override
GVariant *model_name_var = g_variant_dict_lookup_value(options, "model", G_VARIANT_TYPE_STRING); GVariant *model_name_var = g_variant_dict_lookup_value(options, "model", G_VARIANT_TYPE_STRING);
if (model_name_var != NULL) { if (model_name_var != NULL) {
@ -1958,6 +1955,10 @@ static void startup(GApplication *app, gpointer null_ptr) {
g_debug("GTK version %u.%u.%u", gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version()); g_debug("GTK version %u.%u.%u", gtk_get_major_version(), gtk_get_minor_version(), gtk_get_micro_version());
if (gui_data.cli_options.force_software_renderer) {
g_message("Forcing fallback renderer!");
}
else {
// Very ugly workaround for GtkGlArea! // Very ugly workaround for GtkGlArea!
// When a GtkGlArea is realized and it creates a legacy GL 1.4 context // When a GtkGlArea is realized and it creates a legacy GL 1.4 context
// it tries to use GL 2.0 functions to render the window which leads to the application crashing. // it tries to use GL 2.0 functions to render the window which leads to the application crashing.
@ -1966,6 +1967,7 @@ static void startup(GApplication *app, gpointer null_ptr) {
// we just realize and destroy the dummy window and compare the contexts version in the realize callback. // we just realize and destroy the dummy window and compare the contexts version in the realize callback.
gui_data.supports_gl = test_gl_support(); gui_data.supports_gl = test_gl_support();
g_debug("OpenGL supported: %s", gui_data.supports_gl? "Yes" : "No"); g_debug("OpenGL supported: %s", gui_data.supports_gl? "Yes" : "No");
}
gui_data.builder = gtk_builder_new_from_resource(RESOURCE_PREFIX "ui/window.ui"); gui_data.builder = gtk_builder_new_from_resource(RESOURCE_PREFIX "ui/window.ui");
gtk_builder_connect_signals(gui_data.builder, NULL); gtk_builder_connect_signals(gui_data.builder, NULL);
@ -2676,10 +2678,11 @@ int main(int argc, char *argv[]) {
// Define our command line parameters // Define our command line parameters
GOptionEntry entries[] = { GOptionEntry entries[] = {
{ "version", 'v', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Show the application version", NULL }, { "version", 'v', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Show the application version", NULL },
{ "fullscreen", 'f', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, NULL, "Start in fullscreen mode", NULL }, { "fullscreen", 'f', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &gui_data.cli_options.fullscreen, "Start in fullscreen mode", NULL },
{ "bootrom", 'b', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &gui_data.cli_options.boot_rom_path, "Path to the boot ROM to use", "<file path>" }, { "bootrom", 'b', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &gui_data.cli_options.boot_rom_path, "Path to the boot ROM to use", "<file path>" },
{ "model", 'm', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "Override the model type to emulate", "<model type>" }, { "model", 'm', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, NULL, "Override the model type to emulate", "<model type>" },
{ "config", 'c', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &gui_data.cli_options.config_path, "Override the path of the configuration file", "<file path>" }, { "config", 'c', G_OPTION_FLAG_NONE, G_OPTION_ARG_STRING, &gui_data.cli_options.config_path, "Override the path of the configuration file", "<file path>" },
{ "no-gl", 's', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE, &gui_data.cli_options.force_software_renderer, "Do not use OpenGL for rendering", NULL },
{ NULL } { NULL }
}; };
// Setup our command line information // Setup our command line information