mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 03:21:49 +00:00
add canvas:unbind_texture method
This commit is contained in:
parent
7715301d65
commit
b9777cc682
4 changed files with 14 additions and 0 deletions
|
|
@ -66,6 +66,10 @@ void LuaCanvas::createTexture() {
|
|||
texture->setMipMapping(false, true);
|
||||
}
|
||||
|
||||
void LuaCanvas::unbindTexture() {
|
||||
texture.reset();
|
||||
}
|
||||
|
||||
union RGBA {
|
||||
struct {
|
||||
uint8_t r, g, b, a;
|
||||
|
|
@ -99,7 +103,13 @@ static int l_at(State* L) {
|
|||
if (auto pixel = get_at(L, x, y)) {
|
||||
return pushinteger(L, pixel->rgba);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_unbind_texture(State* L) {
|
||||
if (auto canvas = touserdata<LuaCanvas>(L, 1)) {
|
||||
canvas->unbindTexture();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -238,6 +248,7 @@ static std::unordered_map<std::string, lua_CFunction> methods {
|
|||
{"clear", lua::wrap<l_clear>},
|
||||
{"update", lua::wrap<l_update>},
|
||||
{"create_texture", lua::wrap<l_create_texture>},
|
||||
{"unbind_texture", lua::wrap<l_unbind_texture>},
|
||||
{"_set_data", lua::wrap<l_set_data>},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ namespace lua {
|
|||
void update(int extrusion = ATLAS_EXTRUSION);
|
||||
|
||||
void createTexture();
|
||||
void unbindTexture();
|
||||
|
||||
static int createMetatable(lua::State*);
|
||||
inline static std::string TYPENAME = "Canvas";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue