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.
This commit is contained in:
slime
2022-10-01 21:55:59 -03:00
parent 6173c1638d
commit 2466e49fd1
2 changed files with 1 additions and 25 deletions
+1 -1
View File
@@ -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);
}
validateDimensions(renderTarget || !readable);
validateDimensions(true);
samplerState = gfx->getDefaultSamplerState();
-24
View File
@@ -240,30 +240,6 @@ void Texture::createTexture()
glGenTextures(1, &texture);
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);
if (renderTarget && GLAD_ANGLE_texture_usage)
glTexParameteri(gltype, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);