Ver Fonte

Prevent old DevIL errors from causing love errors

Bart van Strien há 14 anos atrás
pai
commit
d60ad99da1
1 ficheiros alterados com 32 adições e 33 exclusões
  1. 32 33
      src/modules/image/devil/ImageData.cpp

+ 32 - 33
src/modules/image/devil/ImageData.cpp

@@ -90,24 +90,24 @@ namespace devil
 
 		bool success = (ilTexImage(width, height, 1, bpp, IL_RGBA, IL_UNSIGNED_BYTE, 0) == IL_TRUE);
 		int err = ilGetError();
-		if (err != IL_NO_ERROR){
-			switch (err) {
-				case IL_ILLEGAL_OPERATION:
-					throw love::Exception("Error: Illegal operation");
-					break;
-				case IL_INVALID_PARAM:
-					throw love::Exception("Error: invalid parameters");
-					break;
-				case IL_OUT_OF_MEMORY:
-					throw love::Exception("Error: out of memory");
-					break;
-				default:
-					throw love::Exception("Error: unknown error");
-					break;
-			}
-		}
 
 		if(!success) {
+			if (err != IL_NO_ERROR){
+				switch (err) {
+					case IL_ILLEGAL_OPERATION:
+						throw love::Exception("Error: Illegal operation");
+						break;
+					case IL_INVALID_PARAM:
+						throw love::Exception("Error: invalid parameters");
+						break;
+					case IL_OUT_OF_MEMORY:
+						throw love::Exception("Error: out of memory");
+						break;
+					default:
+						throw love::Exception("Error: unknown error");
+						break;
+				}
+			}
 			throw love::Exception("Could not decode image data.");
 		}
 
@@ -124,25 +124,24 @@ namespace devil
 		ilBindImage(image);
 		// Try to load the data.
 		bool success = (ilTexImage(width, height, 1, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data) == IL_TRUE);
-		int err = ilGetError();
-		if (err != IL_NO_ERROR){
-			switch (err) {
-				case IL_ILLEGAL_OPERATION:
-					throw love::Exception("Error: Illegal operation");
-					break;
-				case IL_INVALID_PARAM:
-					throw love::Exception("Error: invalid parameters");
-					break;
-				case IL_OUT_OF_MEMORY:
-					throw love::Exception("Error: out of memory");
-					break;
-				default:
-					throw love::Exception("Error: unknown error");
-					break;
-			}
-		}
 
 		if(!success) {
+			if (err != IL_NO_ERROR){
+				switch (err) {
+					case IL_ILLEGAL_OPERATION:
+						throw love::Exception("Error: Illegal operation");
+						break;
+					case IL_INVALID_PARAM:
+						throw love::Exception("Error: invalid parameters");
+						break;
+					case IL_OUT_OF_MEMORY:
+						throw love::Exception("Error: out of memory");
+						break;
+					default:
+						throw love::Exception("Error: unknown error");
+						break;
+				}
+			}
 			throw love::Exception("Could not decode image data.");
 		}
 	}