diff --git a/src/opengl/ogl_bitmap.c b/src/opengl/ogl_bitmap.c
index 7cbdd5a..e853fe5 100644
--- a/src/opengl/ogl_bitmap.c
+++ b/src/opengl/ogl_bitmap.c
@@ -415,11 +415,12 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
    ALLEGRO_BITMAP_OGL *ogl_bitmap = (void *)bitmap;
    int w = bitmap->w;
    int h = bitmap->h;
+   bool post_generate_mipmap = false;
    GLenum e;
    int filter;
    int gl_filters[] = {
-      GL_NEAREST, GL_LINEAR, GL_NEAREST_MIPMAP_LINEAR,
-      GL_LINEAR_MIPMAP_LINEAR
+      GL_NEAREST, GL_LINEAR,
+      GL_NEAREST_MIPMAP_LINEAR, GL_LINEAR_MIPMAP_LINEAR
    };
 
    if (ogl_bitmap->texture == 0) {
@@ -431,9 +432,18 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
       ALLEGRO_ERROR("glBindTexture for texture %d failed (%s).\n",
          ogl_bitmap->texture, error_string(e));
    }
-   
+
    if (bitmap->flags & ALLEGRO_MIPMAP) {
-      glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+      /* If using FBOs, use glGenerateMipmap instead of the GL_GENERATE_MIPMAP
+       * texture parameter.  GL_GENERATE_MIPMAP is deprecated in GL 3.0 so we
+       * may want to use the new method in other cases as well.
+       */
+      if (al_get_opengl_extension_list()->ALLEGRO_GL_EXT_framebuffer_object) {
+         post_generate_mipmap = true;
+      }
+      else {
+         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+      }
    }
 
 #ifndef ALLEGRO_IPHONE
@@ -488,23 +498,21 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
       // the problem try to use multiple textures?
       return false;
    }
-   
+
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 
-   filter = bitmap->flags & ALLEGRO_MIPMAP ? 2 : 0;
+   filter = (bitmap->flags & ALLEGRO_MIPMAP) ? 2 : 0;
    if (bitmap->flags & ALLEGRO_MIN_LINEAR) {
       filter++;
    }
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-      gl_filters[filter]);
-    
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filters[filter]);
+
    filter = 0;
    if (bitmap->flags & ALLEGRO_MAG_LINEAR) {
       filter++;
    }
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
-      gl_filters[filter]);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filters[filter]);
 
 // TODO: To support anisotropy, we would need an API for it. Something
 // like:
@@ -515,6 +523,15 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
    }
 #endif
 
+   if (post_generate_mipmap) {
+      glGenerateMipmap(GL_TEXTURE_2D);
+      e = glGetError();
+      if (e) {
+         ALLEGRO_ERROR("glGenerateMipmap for texture %d failed (%s).\n",
+            ogl_bitmap->texture, error_string(e));
+      }
+   }
+
    ogl_bitmap->left = 0;
    ogl_bitmap->right = (float) w / ogl_bitmap->true_w;
    ogl_bitmap->top = (float) h / ogl_bitmap->true_h;
@@ -855,6 +872,16 @@ static void ogl_unlock_region(ALLEGRO_BITMAP *bitmap)
          ALLEGRO_ERROR("glTexSubImage2D for format %s failed (%s).\n",
             _al_format_name(lock_format), error_string(e));
       }
+
+      /* If using FBOs, we need to regenerate mipmaps explicitly now. */
+      if (al_get_opengl_extension_list()->ALLEGRO_GL_EXT_framebuffer_object) {
+         glGenerateMipmap(GL_TEXTURE_2D);
+         e = glGetError();
+         if (e) {
+            ALLEGRO_ERROR("glGenerateMipmap for texture %d failed (%s).\n",
+               ogl_bitmap->texture, error_string(e));
+         }
+      }
    }
 #else /* ALLEGRO_GP2XWIZ or ALLEGRO_IPHONE */
    if (ogl_bitmap->is_backbuffer) {
