Add --videomodes option to show available video modes
authorKahrl <kahrl@gmx.net>
Thu, 9 May 2013 13:53:29 +0000 (15:53 +0200)
committerSfan5 <sfan5@live.de>
Thu, 9 May 2013 14:30:04 +0000 (16:30 +0200)
doc/minetest.6
src/main.cpp

index b3fdd94d938cb3f1d7f0c079b80e54b3cb2ea309..64dfdd149d2adf817d80967d5110dd2801a6054c 100644 (file)
@@ -61,6 +61,9 @@ Run dedicated server
 \-\-speedtests
 Run speed tests
 .TP
+\-\-videomodes
+List available video modes
+.TP
 \-\-info
 Print more information to console
 .TP
index f2ff88c0c8b1d131d382e794d55dd870e78469b9..b87a3e6d0e7cfa19d585e85db81d3019304a9a21 100644 (file)
@@ -936,6 +936,8 @@ int main(int argc, char *argv[])
        allowed_options.insert(std::make_pair("gameid", ValueSpec(VALUETYPE_STRING,
                        _("Set gameid (\"--gameid list\" prints available ones)"))));
 #ifndef SERVER
+       allowed_options.insert(std::make_pair("videomodes", ValueSpec(VALUETYPE_FLAG,
+                       _("Show available video modes"))));
        allowed_options.insert(std::make_pair("speedtests", ValueSpec(VALUETYPE_FLAG,
                        _("Run speed tests"))));
        allowed_options.insert(std::make_pair("address", ValueSpec(VALUETYPE_STRING,
@@ -1035,7 +1037,7 @@ int main(int argc, char *argv[])
                print_worldspecs(worldspecs, dstream);
                return 0;
        }
-       
+
        // Print startup message
        infostream<<PROJECT_NAME<<
                        " "<<_("with")<<" SER_FMT_VER_HIGHEST="<<(int)SER_FMT_VER_HIGHEST
@@ -1415,11 +1417,64 @@ int main(int argc, char *argv[])
        }
 
        /*
-               Create device and exit if creation failed
+               List video modes if requested
        */
 
        MyEventReceiver receiver;
 
+       if(cmd_args.getFlag("videomodes")){
+               IrrlichtDevice *nulldevice;
+
+               SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
+               params.DriverType    = video::EDT_NULL;
+               params.WindowSize    = core::dimension2d<u32>(640, 480);
+               params.Bits          = 24;
+               params.AntiAlias     = fsaa;
+               params.Fullscreen    = false;
+               params.Stencilbuffer = false;
+               params.Vsync         = vsync;
+               params.EventReceiver = &receiver;
+
+               nulldevice = createDeviceEx(params);
+
+               if(nulldevice == 0)
+                       return 1;
+
+               dstream<<_("Available video modes (WxHxD):")<<std::endl;
+
+               video::IVideoModeList *videomode_list =
+                               nulldevice->getVideoModeList();
+
+               if(videomode_list == 0){
+                       nulldevice->drop();
+                       return 1;
+               }
+
+               s32 videomode_count = videomode_list->getVideoModeCount();
+               core::dimension2d<u32> videomode_res;
+               s32 videomode_depth;
+               for (s32 i = 0; i < videomode_count; ++i){
+                       videomode_res = videomode_list->getVideoModeResolution(i);
+                       videomode_depth = videomode_list->getVideoModeDepth(i);
+                       dstream<<videomode_res.Width<<"x"<<videomode_res.Height
+                                       <<"x"<<videomode_depth<<std::endl;
+               }
+
+               dstream<<_("Active video mode (WxHxD):")<<std::endl;
+               videomode_res = videomode_list->getDesktopResolution();
+               videomode_depth = videomode_list->getDesktopDepth();
+               dstream<<videomode_res.Width<<"x"<<videomode_res.Height
+                               <<"x"<<videomode_depth<<std::endl;
+
+               nulldevice->drop();
+
+               return 0;
+       }
+
+       /*
+               Create device and exit if creation failed
+       */
+
        IrrlichtDevice *device;
 
        SIrrlichtCreationParameters params = SIrrlichtCreationParameters();