1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
io.stdout:setvbuf("no")
local texture_shader_source = [[
#VERTEX_SHADER
Vertex vert(Vertex v)
{
return v;
}
#END_VERTEX_SHADER
#FRAGMENT_SHADER
Color frag(Color c, Texture tex, Vertex v)
{
return c * texel(tex, v.uv);
}
#END_FRAGMENT_SHADER
]]
local texture_shader = nil
local font = nil
function jin.core.onLoad()
texture_shader = jin.graphics.newShader(texture_shader_source)
local fontData = jin.graphics.newBitmap("font.png")
font = jin.graphics.newTexture(fontData)
fontData = nil
end
function jin.core.onEvent(e)
if e.type == "Quit" then
jin.core.stop()
end
if e.type == "KeyDown" and e.key == "Escape" then
jin.core.stop()
end
end
function jin.core.onUpdate(dt)
end
local t = 0
function jin.core.onDraw()
jin.graphics.setClearColor(255, 255, 255, 255)
t = t + 0.01
jin.graphics.setColor(255*math.sin(t), 255*math.cos(t), 255*math.sin(t)*math.cos(t), 255)
jin.graphics.useShader(texture_shader)
jin.graphics.drawq(font, {16, 16, 32, 16}, 10, 10, 5, 5)
--jin.graphics.draw(font, 0, 0, 3, 3)
jin.graphics.unuseShader()
end
|