From 2466e49fd1aadcd6c33653cc6d2b27a83c8ab916 Mon Sep 17 00:00:00 2001 From: slime Date: Sat, 1 Oct 2022 21:55:59 -0300 Subject: [PATCH] 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. --- src/modules/graphics/Texture.cpp | 2 +- src/modules/graphics/opengl/Texture.cpp | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/src/modules/graphics/Texture.cpp b/src/modules/graphics/Texture.cpp index c3ad35fb5..45d284c2f 100644 --- a/src/modules/graphics/Texture.cpp +++ b/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); } - validateDimensions(renderTarget || !readable); + validateDimensions(true); samplerState = gfx->getDefaultSamplerState(); diff --git a/src/modules/graphics/opengl/Texture.cpp b/src/modules/graphics/opengl/Texture.cpp index cff23677a..7b3ec69d8 100644 --- a/src/modules/graphics/opengl/Texture.cpp +++ b/src/modules/graphics/opengl/Texture.cpp @@ -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);