Skip to content

Commit bb1bffa

Browse files
committed
Add test for mutiple textures
1 parent 7cc2911 commit bb1bffa

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

test/mtex.game

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# a small texture size for testing
2+
texture_size : 64
3+
entry : mtex.lua

test/mtex.lua

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
-- To run this sample :
2+
-- bin/soluna.exe test/mtex.game
3+
local soluna = require "soluna"
4+
local ltask = require "ltask"
5+
6+
soluna.set_window_title "multiple texture"
7+
8+
local bundle = {}
9+
10+
local function color(r,g,b)
11+
local name = string.format("%x%x%x", r,g,b)
12+
bundle[#bundle+1] = {
13+
name = r << 8 | g << 4 | b,
14+
filename = "@" .. name,
15+
}
16+
return {
17+
filename = "@" .. name,
18+
content = string.pack("BBBB", r << 4, g << 4, b << 4, 255),
19+
w = 1,
20+
h = 1,
21+
}
22+
end
23+
24+
local function colors()
25+
local results = {}
26+
local n = 1
27+
for r = 0, 15 do
28+
for g = 0, 15 do
29+
for b = 0, 15 do
30+
results[n] = color(r,g,b)
31+
n = n + 1
32+
end
33+
end
34+
end
35+
return results
36+
end
37+
38+
soluna.preload(colors())
39+
40+
local rects = soluna.load_sprites(bundle)
41+
42+
local args = ...
43+
local batch = args.batch
44+
45+
local callback = {}
46+
47+
function callback.frame(count)
48+
batch:layer(10, 100, 100)
49+
for i = 0, 63 do
50+
for j = 0,63 do
51+
batch:add(rects[i * 64 + j], i, j)
52+
end
53+
end
54+
batch:layer()
55+
end
56+
57+
return callback
58+

0 commit comments

Comments
 (0)