Browse Source

Change behaviour of love.graphics.newImage when image size is too big.

Previously it would load a placeholder error texture, now it causes a Lua error - which is the same behaviour as love.graphics.newCanvas.
slime 2 years ago
parent
commit
2466e49fd1
2 changed files with 1 additions and 25 deletions
  1. 1 1
      src/modules/graphics/Texture.cpp
  2. 0 24
      src/modules/graphics/opengl/Texture.cpp

+ 1 - 1
src/modules/graphics/Texture.cpp

@@ -296,7 +296,7 @@ Texture::Texture(Graphics *gfx, const Settings &settings, const Slices *slices)
 		throw love::Exception("%s textures are not supported on this system.", textypestr);
 		throw love::Exception("%s textures are not supported on this system.", textypestr);
 	}
 	}
 
 
-	validateDimensions(renderTarget || !readable);
+	validateDimensions(true);
 
 
 	samplerState = gfx->getDefaultSamplerState();
 	samplerState = gfx->getDefaultSamplerState();
 
 

+ 0 - 24
src/modules/graphics/opengl/Texture.cpp

@@ -240,30 +240,6 @@ void Texture::createTexture()
 	glGenTextures(1, &texture);
 	glGenTextures(1, &texture);
 	gl.bindTextureToUnit(this, 0, false);
 	gl.bindTextureToUnit(this, 0, false);
 
 
-	// Use a default texture if the size is too big for the system.
-	// validateDimensions is also called in the base class for RTs and
-	// non-readable textures.
-	if (!renderTarget && !validateDimensions(false))
-	{
-		usingDefaultTexture = true;
-
-		setSamplerState(samplerState);
-
-		bool isSRGB = false;
-		gl.rawTexStorage(texType, 1, PIXELFORMAT_RGBA8_UNORM, isSRGB, 2, 2, 1);
-
-		// A nice friendly checkerboard to signify invalid textures...
-		GLubyte px[] = {0xFF,0xFF,0xFF,0xFF, 0xFF,0xA0,0xA0,0xFF,
-						0xFF,0xA0,0xA0,0xFF, 0xFF,0xFF,0xFF,0xFF};
-
-		int slices = texType == TEXTURE_CUBE ? 6 : 1;
-		Rect rect = {0, 0, 2, 2};
-		for (int slice = 0; slice < slices; slice++)
-			uploadByteData(PIXELFORMAT_RGBA8_UNORM, px, sizeof(px), 0, slice, rect);
-
-		return;
-	}
-
 	GLenum gltype = OpenGL::getGLTextureType(texType);
 	GLenum gltype = OpenGL::getGLTextureType(texType);
 	if (renderTarget && GLAD_ANGLE_texture_usage)
 	if (renderTarget && GLAD_ANGLE_texture_usage)
 		glTexParameteri(gltype, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
 		glTexParameteri(gltype, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);