From 61877c4eae5d2f8e3b32bb110fd03956186176fc Mon Sep 17 00:00:00 2001
From: jmasterx <joshua_larouche@hotmail.com>
Date: Mon, 16 Feb 2015 21:27:15 -0500
Subject: [PATCH] Fix for OpenGL ES mipmaps not being created when
 ALLEGRO_PROGRAMMABLE_PIPELINE is set on iOS. Currently this is a hack.

---
 src/opengl/ogl_bitmap.c  | 10 +++++++++-
 src/opengl/ogl_lock_es.c |  4 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/opengl/ogl_bitmap.c b/src/opengl/ogl_bitmap.c
index 0671574..a5250be 100644
--- a/src/opengl/ogl_bitmap.c
+++ b/src/opengl/ogl_bitmap.c
@@ -453,11 +453,18 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
        * 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) {
+      if (al_get_opengl_extension_list()->ALLEGRO_GL_EXT_framebuffer_object ||
+          al_get_opengl_extension_list()->ALLEGRO_GL_OES_framebuffer_object ||
+          IS_OPENGLES /* FIXME */) {
          post_generate_mipmap = true;
       }
       else {
          glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+          e = glGetError();
+          if (e) {
+              ALLEGRO_ERROR("glTexParameteri for texture %d failed (%s).\n",
+                            ogl_bitmap->texture, _al_gl_error_string(e));
+          }
       }
    }
 
@@ -498,6 +505,7 @@ static bool ogl_upload_bitmap(ALLEGRO_BITMAP *bitmap)
          ogl_bitmap->true_w, ogl_bitmap->true_h, 0,
          get_glformat(bitmap_format, 2),
          get_glformat(bitmap_format, 1), buf);
+      e = glGetError();
       al_free(buf);
    }
 
diff --git a/src/opengl/ogl_lock_es.c b/src/opengl/ogl_lock_es.c
index 777a954..ef85a3a 100644
--- a/src/opengl/ogl_lock_es.c
+++ b/src/opengl/ogl_lock_es.c
@@ -560,7 +560,9 @@ static void ogl_unlock_region_nonbb(ALLEGRO_BITMAP *bitmap,
    /* If using FBOs, we need to regenerate mipmaps explicitly now. */
    /* XXX why don't we check ogl_bitmap->fbo_info? */
    if ((al_get_bitmap_flags(bitmap) & ALLEGRO_MIPMAP) &&
-      al_get_opengl_extension_list()->ALLEGRO_GL_EXT_framebuffer_object)
+      (al_get_opengl_extension_list()->ALLEGRO_GL_EXT_framebuffer_object ||
+       al_get_opengl_extension_list()->ALLEGRO_GL_OES_framebuffer_object ||
+       IS_OPENGLES /* FIXME */))
    {
       glGenerateMipmapEXT(GL_TEXTURE_2D);
       e = glGetError();
-- 
1.9.2.msysgit.0

