blob: 671cacd4499133336ad4568c541499d939e8f4a8 (
plain)
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
47
48
49
50
51
52
53
|
/* graphics.lua */
static const char* graphics_lua = R"(
jin.graphics = jin.graphics or {}
local default_shader = nil
local default_shader_source = [[
#VERTEX_SHADER
Vertex vert(Vertex v)
{
return v;
}
#END_VERTEX_SHADER
#FRAGMENT_SHADER
Color frag(Color col, Texture tex, Vertex v)
{
return col;
}
#END_FRAGMENT_SHADER
]]
local _init = jin.graphics.init
local initialized = false
jin.graphics.init = function(setting)
if initialized then
return initialized
end
initialized = _init(setting)
if initialized then
default_shader = jin.graphics.newShader(default_shader_source)
jin.graphics.useShader(default_shader)
end
return initialized
end
jin.graphics.unuseShader = function()
jin.graphics.useShader(default_shader)
end
-- Reset all attributes to default value.
jin.graphics.reset = function()
jin.graphics.setColor(255, 255, 255, 255)
jin.graphics.setClearColor(0, 0, 0, 255)
jin.graphics.clear()
jin.graphics.unsetFont()
end
)";
|