Idk what am i missing but i tried to generate a texture that has more that one color but it always shows only one.
self.radius = 200
self.buffer = buffer.create(self.radius * self.radius, { {name=hash("rgb"), type=buffer.VALUE_TYPE_UINT8, count=3} } )
self.stream = buffer.get_stream(self.buffer, hash("rgb"))
for y = 1, self.radius do
for x = 1, self.radius do
local index = (y-1) * self.radius * 3 + (x-1) * 3 + 1
if y < self.radius / 2 then
-- orange
self.stream[index + 0] = 0xff
self.stream[index + 1] = 0x80
self.stream[index + 2] = 0x10
else
-- blue
self.stream[index + 0] = 0x10
self.stream[index + 1] = 0x80
self.stream[index + 2] = 0xff
end
end
end
local resource_path = go.get("#sprite", "texture0")
local header = { width=self.radius, height=self.radius, type=resource.TEXTURE_TYPE_2D, format=resource.TEXTURE_FORMAT_RGB, num_mip_maps=1 }
resource.set_texture( resource_path, header, self.buffer )
the result is just a 200x200 square all in blue, instead of half in blue and another half in orange.