.scr patch (from Raymond Penners)
[blender.git] / source / gameengine / GamePlayer / ghost / GPG_ghost.cpp
index 5f702041c41909b73cf5f5052fc0af2428e8f2ef..d7a9ad2b41dcb6754988ddebb20d0c417a660d0a 100644 (file)
@@ -85,8 +85,8 @@ extern "C"
 #include "BKE_utildefines.h"
 
 #ifdef WIN32
 #include "BKE_utildefines.h"
 
 #ifdef WIN32
-#ifdef NDEBUG
 #include <windows.h>
 #include <windows.h>
+#ifdef NDEBUG
 #include <wincon.h>
 #endif // NDEBUG
 #endif // WIN32
 #include <wincon.h>
 #endif // NDEBUG
 #endif // WIN32
@@ -96,6 +96,62 @@ const int kMinWindowHeight = 100;
 
 char bprogname[FILE_MAXDIR+FILE_MAXFILE];
 
 
 char bprogname[FILE_MAXDIR+FILE_MAXFILE];
 
+#ifdef WIN32
+typedef enum 
+{
+  SCREEN_SAVER_MODE_NONE = 0,
+  SCREEN_SAVER_MODE_PREVIEW,
+  SCREEN_SAVER_MODE_SAVER,
+  SCREEN_SAVER_MODE_CONFIGURATION,
+  SCREEN_SAVER_MODE_PASSWORD,
+} ScreenSaverMode;
+
+static ScreenSaverMode scr_saver_mode = SCREEN_SAVER_MODE_NONE;
+static HWND scr_saver_hwnd = NULL;
+
+static BOOL scr_saver_init(int argc, char **argv) 
+{
+       scr_saver_mode = SCREEN_SAVER_MODE_NONE;
+       scr_saver_hwnd = NULL;
+       BOOL ret = FALSE;
+
+       int len = ::strlen(argv[0]);
+       if (len > 4 && !::stricmp(".scr", argv[0] + len - 4))
+       {
+               scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
+               ret = TRUE;
+               if (argc >= 2)
+               {
+                       if (argc >= 3)
+                       {
+                               scr_saver_hwnd = (HWND) ::atoi(argv[2]);
+                       }
+                       if (!::stricmp("/c", argv[1]))
+                       {
+                               scr_saver_mode = SCREEN_SAVER_MODE_CONFIGURATION;
+                               if (scr_saver_hwnd == NULL)
+                                       scr_saver_hwnd = ::GetForegroundWindow();
+                       }
+                       else if (!::stricmp("/s", argv[1]))
+                       {
+                               scr_saver_mode = SCREEN_SAVER_MODE_SAVER;
+                       }
+                       else if (!::stricmp("/a", argv[1]))
+                       {
+                               scr_saver_mode = SCREEN_SAVER_MODE_PASSWORD;
+                       }
+                       else if (!::stricmp("/p", argv[1])
+                                || !::stricmp("/l", argv[1]))
+                       {
+                               scr_saver_mode = SCREEN_SAVER_MODE_PREVIEW;
+                       }
+               }
+       }
+       return ret;
+}
+
+#endif /* WIN32 */
+
 void usage(char* program)
 {
        char * consoleoption;
 void usage(char* program)
 {
        char * consoleoption;
@@ -124,6 +180,7 @@ void usage(char* program)
        printf("                   syncdoubling     (Above Below)\n");
        printf("                   sidebyside       (Left Right)\n");
        printf("                   anaglyph         (Red-Blue glasses)\n");
        printf("                   syncdoubling     (Above Below)\n");
        printf("                   sidebyside       (Left Right)\n");
        printf("                   anaglyph         (Red-Blue glasses)\n");
+       printf("                   vinterlace       (Vertical interlace for autostereo display)\n");
        printf("                             depending on the type of stereo you want\n");
 #ifdef _WIN32
        printf("  -c: keep console window open\n");
        printf("                             depending on the type of stereo you want\n");
 #ifdef _WIN32
        printf("  -c: keep console window open\n");
@@ -273,15 +330,44 @@ int main(int argc, char** argv)
 #endif // __APPLE__
        
        GEN_init_messaging_system();
 #endif // __APPLE__
        
        GEN_init_messaging_system();
-       
        // Parse command line options
 #ifndef NDEBUG
        printf("argv[0] = '%s'\n", argv[0]);
 #endif
        // Parse command line options
 #ifndef NDEBUG
        printf("argv[0] = '%s'\n", argv[0]);
 #endif
-       for (i = 1; (i < argc) && !error;)
+
+
+#ifdef WIN32
+       if (scr_saver_init(argc, argv))
+       {
+               switch (scr_saver_mode)
+               {
+               case SCREEN_SAVER_MODE_CONFIGURATION:
+                       MessageBox(scr_saver_hwnd, "This screen saver has no options that you can set", "Screen Saver", MB_OK);
+                       break;
+               case SCREEN_SAVER_MODE_PASSWORD:
+                       /* This is W95 only, which we currently do not support.
+                          Fall-back to normal screen saver behaviour in that case... */
+               case SCREEN_SAVER_MODE_SAVER:
+                       fullScreen = true;
+                       fullScreenParFound = true;
+                       break;
+
+               case SCREEN_SAVER_MODE_PREVIEW:
+                       /* This will actually be handled somewhere below... */
+                       break;
+               }
+       }
+#endif
+       for (i = 1; (i < argc) && !error 
+#ifdef WIN32
+               && scr_saver_mode == SCREEN_SAVER_MODE_NONE
+#endif
+               ;)
+
        {
 #ifndef NDEBUG
        {
 #ifndef NDEBUG
-               printf("argv[%d] = '%s'\n", i, argv[i]);
+               printf("argv[%d] = '%s'   , %i\n", i, argv[i],argc);
 #endif
                if (argv[i][0] == '-')
                {
 #endif
                if (argv[i][0] == '-')
                {
@@ -341,6 +427,10 @@ int main(int argc, char** argv)
                                                error = true;
                                                printf("error: too few options for window argument.\n");
                                        }
                                                error = true;
                                                printf("error: too few options for window argument.\n");
                                        }
+                               } else { /* mac specific */
+                               
+                    if (strncmp(argv[i], "-psn_", 5)==0) 
+                        i++; /* skip process serial number */
                                }
                                break;
                        case 'f':
                                }
                                break;
                        case 'f':
@@ -379,6 +469,10 @@ int main(int argc, char** argv)
                                i++;
                                if ((i + 1) < argc)
                                {
                                i++;
                                if ((i + 1) < argc)
                                {
+                                       stereomode = (RAS_IRasterizer::StereoMode) atoi(argv[i]);
+                                       if (stereomode < RAS_IRasterizer::RAS_STEREO_NOSTEREO || stereomode >= RAS_IRasterizer::RAS_STEREO_MAXSTEREO)
+                                               stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
+                                       
                                        if(!strcmp(argv[i], "nostereo"))  // ok, redundant but clear
                                                stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
                                        
                                        if(!strcmp(argv[i], "nostereo"))  // ok, redundant but clear
                                                stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
                                        
@@ -395,6 +489,10 @@ int main(int argc, char** argv)
                                        
                                        if(!strcmp(argv[i], "sidebyside"))
                                                stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
                                        
                                        if(!strcmp(argv[i], "sidebyside"))
                                                stereomode = RAS_IRasterizer::RAS_STEREO_SIDEBYSIDE;
+                                       
+                                       if(!strcmp(argv[i], "vinterlace"))
+                                               stereomode = RAS_IRasterizer::RAS_STEREO_VINTERLACE;
+                                       
 #if 0
                                        // future stuff
                                        if(strcmp(argv[i], "stencil")
 #if 0
                                        // future stuff
                                        if(strcmp(argv[i], "stencil")
@@ -432,6 +530,9 @@ int main(int argc, char** argv)
                usage(argv[0]);
        }
        else
                usage(argv[0]);
        }
        else
+#ifdef WIN32
+               if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION)
+#endif
        {
 #ifdef __APPLE__
                //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1);
        {
 #ifdef __APPLE__
                //SYS_WriteCommandLineInt(syshandle, "show_framerate", 1);
@@ -552,8 +653,18 @@ int main(int argc, char** argv)
                                                        
                                                        if (fullScreen)
                                                        {
                                                        
                                                        if (fullScreen)
                                                        {
-                                                               app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
-                                                                       stereoWindow, stereomode);
+#ifdef WIN32
+                                                               if (scr_saver_mode == SCREEN_SAVER_MODE_SAVER)
+                                                               {
+                                                                       app.startScreenSaverFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
+                                                                               stereoWindow, stereomode);
+                                                               }
+                                                               else
+#endif
+                                                               {
+                                                                       app.startFullScreen(fullScreenWidth, fullScreenHeight, fullScreenBpp, fullScreenFrequency,
+                                                                               stereoWindow, stereomode);
+                                                               }
                                                        }
                                                        else
                                                        {
                                                        }
                                                        else
                                                        {
@@ -589,8 +700,17 @@ int main(int argc, char** argv)
                                                                {
                                                                        title = "blenderplayer";
                                                                }
                                                                {
                                                                        title = "blenderplayer";
                                                                }
-                                                               app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
-                                                                       stereoWindow, stereomode);
+#ifdef WIN32
+                                                               if (scr_saver_mode == SCREEN_SAVER_MODE_PREVIEW)
+                                                               {
+                                                                       app.startScreenSaverPreview(scr_saver_hwnd, stereoWindow, stereomode);
+                                                               }
+                                                               else
+#endif
+                                                               {
+                                                                       app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
+                                                                               stereoWindow, stereomode);
+                                                               }
                                                        }
                                                }
                                                else
                                                        }
                                                }
                                                else