mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-05 19:11:50 +00:00
fix canvas:set_data
This commit is contained in:
parent
5436b98f3b
commit
66bb734a4e
2 changed files with 10 additions and 2 deletions
|
|
@ -220,6 +220,14 @@ static int l_set_data(State* L) {
|
|||
|
||||
if (lua::isstring(L, 2)) {
|
||||
auto ptr = reinterpret_cast<ubyte*>(std::stoull(lua::tostring(L, 2)));
|
||||
int len = lua::touinteger(L, 3);
|
||||
if (len < image.getDataSize()) {
|
||||
throw std::runtime_error(
|
||||
"data size mismatch expected " +
|
||||
std::to_string(image.getDataSize()) + ", got " +
|
||||
std::to_string(len)
|
||||
);
|
||||
}
|
||||
std::memcpy(data, ptr, image.getDataSize());
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue