image.gl_load: moving error cleaning to before all gl calls"
authorDalai Felinto <dfelinto@gmail.com>
Mon, 28 May 2012 17:47:42 +0000 (17:47 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Mon, 28 May 2012 17:47:42 +0000 (17:47 +0000)
source/blender/makesrna/intern/rna_image_api.c

index 336f033eae4c65077dd7c8088be31da2b8776876..124a7a7e2b113d9e61775624595ec06258da3138 100644 (file)
@@ -207,15 +207,16 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int filter, int
                error = (int)gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 
        if (!error) {
+               /* clean glError buffer */
+               while (glGetError() != GL_NO_ERROR){};
+
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, image->tpageflag & IMA_CLAMP_U ? GL_CLAMP : GL_REPEAT);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, image->tpageflag & IMA_CLAMP_V ? GL_CLAMP : GL_REPEAT);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLint)filter);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLint)mag);
                glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ibuf->x, ibuf->y, 0, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
-
-               while (error != GL_NO_ERROR)
-                       error = (int)glGetError();
+               error = (int)glGetError();
        }
 
        if (error) {