I had a look at this and it seems fine to me. I made a few trivial wording changes so that the intended use is a bit clearer. I don't have the input lag issue myself, but I did test that it doesn't seem to have any adverse effects with my nVidia card. Unless anyone has any further comments I'll commit the patch below on the weekend.
diff --git a/code/cmdline/cmdline.cpp b/code/cmdline/cmdline.cpp
index 51bebda..d5ae196 100644
--- a/code/cmdline/cmdline.cpp
+++ b/code/cmdline/cmdline.cpp
@@ -194,6 +194,7 @@ Flag exe_params[] =
#endif
{ "-use_gldrawelements","Don't use glDrawRangeElements", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-use_gldrawelements", },
{ "-old_collision", "Use old collision detection system", true, EASY_DEFAULT, EASY_ALL_ON, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-old_collision", },
+ { "-gl_finish", "Fix input lag on some ATI+Linux systems", true, 0, EASY_DEFAULT, "Troubleshoot", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-gl_finish", },
{ "-ingame_join", "Allow in-game joining", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-ingame_join", },
{ "-voicer", "Enable voice recognition", true, 0, EASY_DEFAULT, "Experimental", "http://www.hard-light.net/wiki/index.php/Command-Line_Reference#-voicer", },
@@ -412,6 +413,7 @@ cmdline_parm no_di_mouse_arg("-disable_di_mouse", "Disable DirectInput mouse cod
cmdline_parm no_drawrangeelements("-use_gldrawelements", NULL, AT_NONE); // Cmdline_drawelements -- Uses glDrawElements instead of glDrawRangeElements
cmdline_parm keyboard_layout("-keyboard_layout", "Specify keyboard layout (qwertz or azerty)", AT_STRING);
cmdline_parm old_collision_system("-old_collision", NULL, AT_NONE); // Cmdline_old_collision_sys
+cmdline_parm gl_finish ("-gl_finish", NULL, AT_NONE);
int Cmdline_load_all_weapons = 0;
int Cmdline_nohtl = 0;
@@ -428,6 +430,7 @@ int Cmdline_no_glsl_model_rendering = 0;
int Cmdline_no_di_mouse = 0;
int Cmdline_drawelements = 0;
char* Cmdline_keyboard_layout = NULL;
+bool Cmdline_gl_finish = false;
// Developer/Testing related
cmdline_parm start_mission_arg("-start_mission", "Skip mainhall and run this mission", AT_STRING); // Cmdline_start_mission
@@ -1487,6 +1490,11 @@ bool SetCmdlineParams()
Cmdline_keyboard_layout = keyboard_layout.str();
}
+ if (gl_finish.found())
+ {
+ Cmdline_gl_finish = true;
+ }
+
if ( snd_preload_arg.found() )
{
Cmdline_snd_preload = 1;
diff --git a/code/cmdline/cmdline.h b/code/cmdline/cmdline.h
index 9e36ed1..117a35c 100644
--- a/code/cmdline/cmdline.h
+++ b/code/cmdline/cmdline.h
@@ -130,6 +130,7 @@ extern int Cmdline_no_glsl_model_rendering;
extern int Cmdline_no_di_mouse;
extern int Cmdline_drawelements;
extern char* Cmdline_keyboard_layout;
+extern bool Cmdline_gl_finish;
// Developer/Testing related
extern char *Cmdline_start_mission;
diff --git a/code/graphics/gropengl.cpp b/code/graphics/gropengl.cpp
index 8c3888e..abd4ca3 100644
--- a/code/graphics/gropengl.cpp
+++ b/code/graphics/gropengl.cpp
@@ -354,6 +354,8 @@ void gr_opengl_flip()
#ifdef _WIN32
SwapBuffers(GL_device_context);
#else
+ if (Cmdline_gl_finish)
+ glFinish ();
SDL_GL_SwapBuffers();
#endif