add canvas:unbind_texture method
This commit is contained in:
parent
7715301d65
commit
b9777cc682
@ -196,6 +196,7 @@ Here, *color* can be specified in the following ways:
|
|||||||
| data:update() | applies changes to the canvas and uploads it to the GPU |
|
| data:update() | applies changes to the canvas and uploads it to the GPU |
|
||||||
| data:set_data(data: table<int>) | replaces pixel data (width * height * 4 numbers) |
|
| data:set_data(data: table<int>) | replaces pixel data (width * height * 4 numbers) |
|
||||||
| data:create_texture(name: str) | creates and shares texture to renderer |
|
| data:create_texture(name: str) | creates and shares texture to renderer |
|
||||||
|
| data:unbind_texture() | unbinds the texture from the canvas |
|
||||||
|
|
||||||
## Inline frame (iframe)
|
## Inline frame (iframe)
|
||||||
|
|
||||||
|
|||||||
@ -196,6 +196,7 @@ document["worlds-panel"]:clear()
|
|||||||
| data:update() | применяет изменения и загружает холст в видеопамять |
|
| data:update() | применяет изменения и загружает холст в видеопамять |
|
||||||
| data:set_data(data: table<int>) | заменяет данные пикселей (ширина * высота * 4 чисел) |
|
| data:set_data(data: table<int>) | заменяет данные пикселей (ширина * высота * 4 чисел) |
|
||||||
| data:create_texture(name: str) | создаёт и делится текстурой с рендерером |
|
| data:create_texture(name: str) | создаёт и делится текстурой с рендерером |
|
||||||
|
| data:unbind_texture() | отвязывает текстуру от холста |
|
||||||
|
|
||||||
## Рамка встраивания (iframe)
|
## Рамка встраивания (iframe)
|
||||||
|
|
||||||
|
|||||||
@ -66,6 +66,10 @@ void LuaCanvas::createTexture() {
|
|||||||
texture->setMipMapping(false, true);
|
texture->setMipMapping(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaCanvas::unbindTexture() {
|
||||||
|
texture.reset();
|
||||||
|
}
|
||||||
|
|
||||||
union RGBA {
|
union RGBA {
|
||||||
struct {
|
struct {
|
||||||
uint8_t r, g, b, a;
|
uint8_t r, g, b, a;
|
||||||
@ -99,7 +103,13 @@ static int l_at(State* L) {
|
|||||||
if (auto pixel = get_at(L, x, y)) {
|
if (auto pixel = get_at(L, x, y)) {
|
||||||
return pushinteger(L, pixel->rgba);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +248,7 @@ static std::unordered_map<std::string, lua_CFunction> methods {
|
|||||||
{"clear", lua::wrap<l_clear>},
|
{"clear", lua::wrap<l_clear>},
|
||||||
{"update", lua::wrap<l_update>},
|
{"update", lua::wrap<l_update>},
|
||||||
{"create_texture", lua::wrap<l_create_texture>},
|
{"create_texture", lua::wrap<l_create_texture>},
|
||||||
|
{"unbind_texture", lua::wrap<l_unbind_texture>},
|
||||||
{"_set_data", lua::wrap<l_set_data>},
|
{"_set_data", lua::wrap<l_set_data>},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,7 @@ namespace lua {
|
|||||||
void update(int extrusion = ATLAS_EXTRUSION);
|
void update(int extrusion = ATLAS_EXTRUSION);
|
||||||
|
|
||||||
void createTexture();
|
void createTexture();
|
||||||
|
void unbindTexture();
|
||||||
|
|
||||||
static int createMetatable(lua::State*);
|
static int createMetatable(lua::State*);
|
||||||
inline static std::string TYPENAME = "Canvas";
|
inline static std::string TYPENAME = "Canvas";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user