possible crash fixes

This commit is contained in:
LightCat 2018-09-17 19:12:32 +02:00
parent d99d5fcb7f
commit 7ccff46237

View File

@ -48,19 +48,26 @@ void texture::bind()
void texture::load(const std::string &path)
{
png::image<png::rgba_pixel> image(path);
width = image.get_width();
height = image.get_height();
init = true;
bound = false;
id = 0;
auto bytes = image.get_width() * image.get_height() * 4;
data = new GLubyte[bytes];
for (int i = 0; i < image.get_height(); ++i)
try
{
memcpy(data + image.get_width() * 4 * i,
image.get_pixbuf().get_row(i).data(), image.get_width() * 4);
png::image<png::rgba_pixel> image(path);
width = image.get_width();
height = image.get_height();
init = true;
bound = false;
id = 0;
auto bytes = image.get_width() * image.get_height() * 4;
data = new GLubyte[bytes];
for (int i = 0; i < image.get_height(); ++i)
{
memcpy(data + image.get_width() * 4 * i,
image.get_pixbuf().get_row(i).data(), image.get_width() * 4);
}
}
catch (...)
{
}
}
@ -87,4 +94,4 @@ unsigned create()
cache->push_back(texture{});
return result;
}
}
}