aboutsummaryrefslogtreecommitdiff
path: root/games/devtest/mods/testnodes/textures/testnodes_liquidflowing_r6.png
blob: 4cd8e4e8e551a3c8881ce47e3bcf788fdc065c2e (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 10 00 00 00 10 08 06 00 00 00 1f f3 ff .PNG........IHDR................
0020 61 00 00 00 62 49 44 41 54 78 01 63 60 e8 30 de 0c c6 cb 1c c0 98 54 3e e5 06 a0 4b 90 cc c7 a6 a...bIDATx.c`.0.......T>...K....
0040 c0 ef 48 e9 e6 e0 75 05 20 0c 62 c3 f8 38 0c c0 34 19 5d 23 8c 4f 74 18 c0 34 90 1d 06 f8 9d 3c ..H...u...b..8..4.]#.Ot..4.....<
0060 1a 06 20 39 18 06 f1 c9 33 80 79 99 e3 66 e6 4e 0b 10 9f 64 2f 20 bb 80 ac bc 00 73 3a 88 26 98 ...9....3.y..f.N...d/......s:.&.
0080 17 c8 0b 03 52 f9 00 ce ea a4 1e b7 ff 78 01 00 00 00 00 49 45 4e 44 ae 42 60 82 ....R........x.....IEND.B`.
' href='#n66'>66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
--- irrlicht/source/Irrlicht/COGLESTexture.cpp.orig	2014-06-22 17:01:13.266568869 +0200
+++ irrlicht/source/Irrlicht/COGLESTexture.cpp	2014-06-22 17:03:59.298572810 +0200
@@ -366,112 +366,140 @@
 	void(*convert)(const void*, s32, void*) = 0;
 	getFormatParameters(ColorFormat, InternalFormat, filtering, PixelFormat, PixelType, convert);
 
-	// make sure we don't change the internal format of existing images
-	if (!newTexture)
-		InternalFormat = oldInternalFormat;
-
-    Driver->setActiveTexture(0, this);
-
-	if (Driver->testGLError())
-		os::Printer::log("Could not bind Texture", ELL_ERROR);
-
-	// mipmap handling for main texture
-	if (!level && newTexture)
-	{
-		// auto generate if possible and no mipmap data is given
-		if (!IsCompressed && HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
-		{
-			if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
-				glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
-			else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
-				glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
-			else
-				glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);
+	bool retry = false;
+	
+	do { 
+		if (retry) {
+			InternalFormat = GL_RGBA;
+			PixelFormat = GL_RGBA;
+			convert = CColorConverter::convert_A8R8G8B8toA8B8G8R8;
+ 		}
+		// make sure we don't change the internal format of existing images
+		if (!newTexture)
+			InternalFormat = oldInternalFormat;
 
-            glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
-			AutomaticMipmapUpdate=true;
-		}
+		Driver->setActiveTexture(0, this);
 
-		// enable bilinear filter without mipmaps
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
-	}
+		if (Driver->testGLError())
+			os::Printer::log("Could not bind Texture", ELL_ERROR);
 
-	// now get image data and upload to GPU
+		// mipmap handling for main texture
+		if (!level && newTexture)
+		{
+			// auto generate if possible and no mipmap data is given
+			if (!IsCompressed && HasMipMaps && !mipmapData && Driver->queryFeature(EVDF_MIP_MAP_AUTO_UPDATE))
+			{
+				if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_SPEED))
+					glHint(GL_GENERATE_MIPMAP_HINT, GL_FASTEST);
+				else if (Driver->getTextureCreationFlag(ETCF_OPTIMIZED_FOR_QUALITY))
+					glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
+				else
+					glHint(GL_GENERATE_MIPMAP_HINT, GL_DONT_CARE);
+
+				glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
+				AutomaticMipmapUpdate=true;
+			}
+
+			// enable bilinear filter without mipmaps
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
+			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+		}
 
-	u32 compressedImageSize = IImage::getCompressedImageSize(ColorFormat, image->getDimension().Width, image->getDimension().Height);
+		// now get image data and upload to GPU
 
-	void* source = image->lock();
+		u32 compressedImageSize = IImage::getCompressedImageSize(ColorFormat, image->getDimension().Width, image->getDimension().Height);
 
-	IImage* tmpImage = 0;
+		void* source = image->lock();
 
-	if (convert)
-	{
-		tmpImage = new CImage(image->getColorFormat(), image->getDimension());
-		void* dest = tmpImage->lock();
-		convert(source, image->getDimension().getArea(), dest);
-		image->unlock();
-		source = dest;
-	}
+		IImage* tmpImage = 0;
 
-	if (newTexture)
-	{
-		if (IsCompressed)
+		if (convert)
 		{
-			glCompressedTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, image->getDimension().Width,
-				image->getDimension().Height, 0, compressedImageSize, source);
+			tmpImage = new CImage(image->getColorFormat(), image->getDimension());
+			void* dest = tmpImage->lock();
+			convert(source, image->getDimension().getArea(), dest);
+			image->unlock();
+			source = dest;
 		}
-		else
-			glTexImage2D(GL_TEXTURE_2D, level, InternalFormat, image->getDimension().Width,
-				image->getDimension().Height, 0, PixelFormat, PixelType, source);
-	}
-	else
-	{
-		if (IsCompressed)
+
+		if (newTexture)
 		{
-			glCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
-				image->getDimension().Height, PixelFormat, compressedImageSize, source);
+			if (IsCompressed)
+			{
+				glCompressedTexImage2D(GL_TEXTURE_2D, 0, InternalFormat, image->getDimension().Width,
+					image->getDimension().Height, 0, compressedImageSize, source);
+			}
+			else
+				glTexImage2D(GL_TEXTURE_2D, level, InternalFormat, image->getDimension().Width,
+					image->getDimension().Height, 0, PixelFormat, PixelType, source);
 		}
 		else
-			glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
-				image->getDimension().Height, PixelFormat, PixelType, source);
-	}
-
-	if (convert)
-	{
-		tmpImage->unlock();
-		tmpImage->drop();
-	}
-	else
-		image->unlock();
-
-	if (!level && newTexture)
-	{
-		if (IsCompressed && !mipmapData)
 		{
-			if (image->hasMipMaps())
-				mipmapData = static_cast<u8*>(image->lock())+compressedImageSize;
+			if (IsCompressed)
+			{
+				glCompressedTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
+					image->getDimension().Height, PixelFormat, compressedImageSize, source);
+			}
 			else
-				HasMipMaps = false;
+				glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, image->getDimension().Width,
+					image->getDimension().Height, PixelFormat, PixelType, source);
 		}
 
-		regenerateMipMapLevels(mipmapData);
-
-		if (HasMipMaps) // might have changed in regenerateMipMapLevels
+		if (convert)
 		{
-			// enable bilinear mipmap filter
-			GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST;
-
-			if (filtering != GL_LINEAR)
-				filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST;
+			tmpImage->unlock();
+			tmpImage->drop();
+		}
+		else
+			image->unlock();
+		
+		if (glGetError() != GL_NO_ERROR) {
+			static bool warned = false;
+			if ((!retry) && (ColorFormat == ECF_A8R8G8B8)) {
+
+				if (!warned) {
+					os::Printer::log("Your driver claims to support GL_BGRA but fails on trying to upload a texture, converting to GL_RGBA and trying again", ELL_ERROR);
+					warned = true;
+				}
+			}
+			else if (retry) {
+				os::Printer::log("Neither uploading texture as GL_BGRA nor, converted one using GL_RGBA succeeded", ELL_ERROR);
+			}
+			retry = !retry;
+			continue;
+		} else {
+			retry = false;
+		}
 
-			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps);
-			glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+		if (!level && newTexture)
+		{
+			if (IsCompressed && !mipmapData)
+			{
+				if (image->hasMipMaps())
+					mipmapData = static_cast<u8*>(image->lock())+compressedImageSize;
+				else
+					HasMipMaps = false;
+			}
+
+			regenerateMipMapLevels(mipmapData);
+
+			if (HasMipMaps) // might have changed in regenerateMipMapLevels
+			{
+				// enable bilinear mipmap filter
+				GLint filteringMipMaps = GL_LINEAR_MIPMAP_NEAREST;
+
+				if (filtering != GL_LINEAR)
+					filteringMipMaps = GL_NEAREST_MIPMAP_NEAREST;
+
+				glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filteringMipMaps);
+				glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
+			}
 		}
-	}
 
-	if (Driver->testGLError())
-		os::Printer::log("Could not glTexImage2D", ELL_ERROR);
+		if (Driver->testGLError())
+			os::Printer::log("Could not glTexImage2D", ELL_ERROR);
+	}
+	while(retry);
 }