Stereo Hack
[mercenary-reloaded.git] / src / mercenary / main.c
index e62944b..5d7ea31 100644 (file)
@@ -67,9 +67,11 @@ static int config_multisampling = 8;
 #ifdef HAVE_OVR
 static double config_benson_size = 0.7;
 static double config_fov = FOV_JOLLY;
+static int config_stereo = 1;
 #else
 static double config_benson_size = 1.0;
 static double config_fov = FOV_NOVAGEN;
+static int config_stereo = 0;
 #endif
 static double config_monitor_distance = 41.5; /* inch */
 #ifdef HAVE_OVR
@@ -193,6 +195,10 @@ int parse_args(int argc, char *argv[])
                        print_info("        stretched. This compensates the vertical stretch of NTSC vs PAL video.\n");
                        print_info("        The original (stretched) sphere makes the game authentic.\n");
                        print_info("        This option requires OpenGL rendering. (default = %d)\n", config_improve_round_planets);
+#ifndef HAVE_OVR
+                       print_info("    --stereo\n");
+                       print_info("        Render Stereoscopic side-by-side.\n");
+#endif
                        print_info("Debug options:\n");
                        print_info(" -o --debug-opengl\n");
                        print_info("        Use split screen to display both Amiga and OpenGL rendering.\n");
@@ -325,6 +331,11 @@ illegal_parameter:
                                goto missing_parameter;
                        config_improve_round_planets = atoi(argv[i]);
                } else
+#ifndef HAVE_OVR
+               if (!strcmp(argv[i], "--stereo")) {
+                       config_stereo = 1;
+               } else
+#endif
                if (!strcmp(argv[i], "-o") || !strcmp(argv[i], "--debug-opengl")) {
                        config_debug_opengl = 1;
                } else
@@ -691,8 +702,8 @@ static void main_loop(void)
        uint32_t palette_address;
        uint16_t palette[16];
        int all_white = 0;
-#ifdef HAVE_OVR
        int eye;
+#ifdef HAVE_OVR
        int vr = 1;
 #else
        int vr = 0;
@@ -772,21 +783,24 @@ static void main_loop(void)
                /* STEP 2: transfer legacy image (or just benson) in memory to OpenGL texture */
 #ifdef HAVE_OVR
                begin_render_ovr();
+#else
+               /* clear screen */
+               opengl_clear(vr);
+#endif
 
-               for (eye = 0; eye < 2; eye++) {
+               for (eye = 0; eye < ((config_stereo) ? 2 : 1); eye++) {
+#ifdef HAVE_OVR
                        double camera_x, camera_y, camera_z;
                        /* begin of rendering eye, viewport and frustum is set here */
                        begin_render_ovr_eye(eye, &camera_x, &camera_y, &camera_z);
-#else
-               {
-#endif
                        /* clear screen */
                        opengl_clear(vr);
+#endif
                        /* render benson + osd ontop of improved opengl rendering, if enabled */
                        if (render_improved) {
 #ifndef HAVE_OVR
                                /* viewport and frustum is set here */
-                               opengl_viewport(window_width, window_height, (debug_opengl) ? 2 : 0, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, benson_size);
+                               opengl_viewport(window_width, window_height, (debug_opengl) ? 2 : 0, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, config_fov, benson_size, (config_stereo) ? eye : -1);
 #endif
                                /* render improved graphics, interpolate, if required,
                                 * if no item list is available, for legacy rendering
@@ -829,7 +843,7 @@ static void main_loop(void)
                                        emul_video(image, memory, palette, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_DIWSTART, chipreg, 0, BENSON_AT_LINE, double_pixel_size);
 #ifndef HAVE_OVR
                                /* viewport and frustum is set here */
-                               opengl_viewport(window_width, window_height, (debug_opengl) ? 1 : 0, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, FOV_NOVAGEN, 1.0);
+                               opengl_viewport(window_width, window_height, (debug_opengl) ? 1 : 0, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, FOV_NOVAGEN, 1.0, (config_stereo) ? eye : -1);
 #endif
                                opengl_blit_image(image, config_video_filter, (double_pixel_size) ? BENSON_AT_LINE * 2 : BENSON_AT_LINE, 0, FOV_NOVAGEN, config_monitor_distance, 1.0, 0);
                                if (help_view)