aboutsummaryrefslogtreecommitdiff
path: root/src/lua/embed/graphics.lua.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-10-23 12:23:58 +0800
committerchai <chaifix@163.com>2018-10-23 12:23:58 +0800
commit40fc27154fe754181934dc7ee31375e6bdfb33fc (patch)
tree897ad98d759bc308ef66561181ba88b85f2ccd47 /src/lua/embed/graphics.lua.h
parent1480c9445100075c9e1a894eb07c0ef727b509a1 (diff)
*merge from minimal
Diffstat (limited to 'src/lua/embed/graphics.lua.h')
-rw-r--r--src/lua/embed/graphics.lua.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lua/embed/graphics.lua.h b/src/lua/embed/graphics.lua.h
new file mode 100644
index 0000000..5fa5dad
--- /dev/null
+++ b/src/lua/embed/graphics.lua.h
@@ -0,0 +1,46 @@
+/* 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 * texel(tex, v.uv);
+}
+
+#END_FRAGMENT_SHADER
+]]
+
+local _init = jin.graphics.init
+
+jin.graphics.init = function(setting)
+ _init(setting);
+ default_shader = jin.graphics.newShader(default_shader_source)
+ jin.graphics.useShader(default_shader)
+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
+
+)";