Fix viewport resize and cleanup code structure of viewport width and height
[mercenary-reloaded.git] / src / libsdl / opengl.c
index 9a6578c..b87e12b 100644 (file)
@@ -34,7 +34,6 @@ static uint8_t *image_rgb = NULL;
 static uint8_t *osd_rgba[MAX_OSD] = { NULL, NULL };
 static GLuint image_name;
 static GLuint osd_name[MAX_OSD];
-static int screen_width, screen_height;
 static int image_width, image_height;
 static int osd_width[MAX_OSD], osd_height[MAX_OSD];
 static int texture_size;
@@ -112,13 +111,6 @@ error:
        return rc;
 }
 
-/* set clip planes so that the image portion of the image texture is centered and pixels are rectengular */
-void resize_opengl(int _screen_width, int _screen_height)
-{
-       screen_width = _screen_width;
-       screen_height = _screen_height;
-}
-
 void opengl_clear(int _flip_y)
 {
        flip_y = _flip_y;
@@ -129,28 +121,17 @@ void opengl_clear(int _flip_y)
 }
 
 /* set viewport for improved rendering */
-void opengl_viewport(int split, int benson_at_line, double fov, double benson_size)
+void opengl_viewport(int view_width, int view_height, int split, int benson_at_line, double fov, double benson_size)
 {
-       int view_x, view_y;
-       int view_width, view_height;
+       int view_x = 0, view_y = 0;
        int new_width, new_height;
 
        /* center view, or put it in the top half of the window */
        if (split == 1) {
-               view_x = 0;
-               view_y = screen_height / 2;
-               view_width = screen_width;
-               view_height = screen_height / 2;
+               view_y = view_height / 2;
+               view_height = view_height / 2;
        } else if (split == 2) {
-               view_x = 0;
-               view_y = 0;
-               view_width = screen_width;
-               view_height = screen_height / 2;
-       } else {
-               view_x = 0;
-               view_y = 0;
-               view_width = screen_width;
-               view_height = screen_height;
+               view_height = view_height / 2;
        }
 
        /* avoid division by zero, if one dimension is too small */