possible crash fixes
This commit is contained in:
parent
d99d5fcb7f
commit
7ccff46237
@ -48,19 +48,26 @@ void texture::bind()
|
|||||||
|
|
||||||
void texture::load(const std::string &path)
|
void texture::load(const std::string &path)
|
||||||
{
|
{
|
||||||
png::image<png::rgba_pixel> image(path);
|
try
|
||||||
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,
|
png::image<png::rgba_pixel> image(path);
|
||||||
image.get_pixbuf().get_row(i).data(), image.get_width() * 4);
|
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{});
|
cache->push_back(texture{});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user