src/Graphics.cc
changeset 392 6c4dc68360eb
parent 389 e74c1820fbd2
child 393 5dd4d782cf3a
--- a/src/Graphics.cc	Tue Jan 13 21:14:12 2009 +0200
+++ b/src/Graphics.cc	Tue Jan 13 21:36:43 2009 +0200
@@ -25,6 +25,24 @@
     return CL_DisplayMode::get_display_modes();
 }
 
+const CL_DisplayMode Graphics::getBestMode (void) {
+    const std::vector<CL_DisplayMode> &modes = Graphics::getDisplayModes();
+
+    const CL_DisplayMode *best_mode = NULL;
+    
+    for (std::vector<CL_DisplayMode>::const_iterator it = modes.begin(); it != modes.end(); it++)
+        if (best_mode == NULL || (
+                it->get_resolution().width * it->get_resolution().height > 
+                best_mode->get_resolution().width * best_mode->get_resolution().height    
+        ))
+            best_mode = &*it;
+    
+    if (best_mode == NULL)
+        throw Error("No available video modes!");
+    
+    return *best_mode;
+}
+
 void Graphics::check_input (void) {
     LocalPlayer *player;
     PlayerInput input_mask;