diff --git a/src/opengl.c b/src/opengl.c
index d531241..dc2a076 100644
--- a/src/opengl.c
+++ b/src/opengl.c
@@ -858,6 +858,7 @@ void gl_checkErr(void) {
 
 /* Initialize SDL/OpenGL etc. */
 int gl_init(void) {
+  double dmin;
   int doublebuf, depth, i, j, off, toff, supported, fsaa;
   SDL_Rect** modes;
   int flags = SDL_OPENGL;
@@ -958,7 +959,11 @@ int gl_init(void) {
     }
   }
 
-  /* Grab some info. */
+  /* Save real window width/height. */
+  gl_screen.rw = SCREEN_W;
+  gl_screen.rh = SCREEN_H;
+
+  /* Get info about the OpenGL window. */
   SDL_GL_GetAttribute(SDL_GL_RED_SIZE,            &gl_screen.r);
   SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE,          &gl_screen.g);
   SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE,           &gl_screen.b);
@@ -1014,6 +1019,18 @@ int gl_init(void) {
   glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); /* Good blend model. */
 
   /* Set up the matrix. */
+  dmin = 1.;
+  if((SCREEN_W < 640) && (SCREEN_W <= SCREEN_H)) {
+    gl_screen.w   = (gl_screen.w  * 640)      / SCREEN_H;
+    gl_screen.rw  = (gl_screen.rw * SCREEN_H) / 640;
+    gl_screen.h   = 640;
+  }
+  else if((SCREEN_W >= 640) && (SCREEN_W >= SCREEN_H)) {
+    gl_screen.w   = (gl_screen.w  * 640)      / SCREEN_H;
+    gl_screen.rw  = (gl_screen.rw * SCREEN_H) / 640;
+    gl_screen.h   = 640; 
+  }
+  DEBUG("%dx%d on %dx%d", gl_screen.w, gl_screen.h, gl_screen.rw, gl_screen.rh);
   gl_defViewport();
 
   /* Finishing touches. */
@@ -1027,12 +1044,14 @@ int gl_init(void) {
 void gl_defViewport(void) {
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
+  /*glViewport(0, 0, (GLsizei)SCREEN_W, (GLsizei)SCREEN_H);*/
   glOrtho(-SCREEN_W /2,   /* Left edge. */
           SCREEN_W  /2,   /* Right edge. */
           -SCREEN_H /2,   /* Bottom edge. */
           SCREEN_H  /2,   /* Top edge. */
           -1.,            /* Near. */
           1.);            /* Far. */
+  glScaled(gl_screen.w / gl_screen.rw, gl_screen.h / gl_screen.rh, 1.);
 }
 
 /* Clean up our mess. */
diff --git a/src/opengl.h b/src/opengl.h
index 41ba7a1..17d22ea 100644
--- a/src/opengl.h
+++ b/src/opengl.h
@@ -38,8 +38,10 @@
  * @brief Store data about the current opengl environment.
  */
 typedef struct glInfo_ {
-  int w;            /**< Window width. */
-  int h;            /**< Window height. */
+  int w;            /**< Window viewport width. */
+  int h;            /**< Window viewport height. */
+  int rw;           /**< Real window width. */
+  int rh;           /**< Real window height. */
   int depth;        /**< Depth in bpp. */
   int r;            /**< Amount of red bits. */
   int g;            /**< Amount of green bits. */