I have something which I don’t think is ideal:
self.preview_buf = buffer.create(PREVIEW_WIDTH * PREVIEW_HEIGHT,
{ { name = hash("rgb"), type = buffer.VALUE_TYPE_UINT8, count = 3 } })
local tstream = buffer.get_stream(self.preview_buf, hash("rgb"))
for x = 0, PREVIEW_WIDTH - 1 do
for y = 0, PREVIEW_HEIGHT - 1 do
i = 3 * (y * PREVIEW_WIDTH + x) + 1
tstream[i + 0] = 0x33
tstream[i + 1] = 0x33
tstream[i + 2] = 0x33
end
end
if gui.new_texture("preview_tex", PREVIEW_WIDTH, PREVIEW_HEIGHT, "rgb",
buffer.get_bytes(self.preview_buf, hash("rgb")),
false) then
gui.set_texture(self.preview, "preview_tex")
end
I still have to create a new texture each update. I would prefer not needing that.