summaryrefslogtreecommitdiff
path: root/honey/shader.lua
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2023-03-22 12:46:23 -0500
committersanine-a <sanine.not@pm.me>2023-03-22 12:46:23 -0500
commit92803015adf19848c3f3a30caea889006ad05999 (patch)
treed3a3a325664ebb3f2b8c214217dce31746a1ae9a /honey/shader.lua
parent16bcc6daab84373cac0f4125c1580d3cb1261baf (diff)
tidy up main.lua
Diffstat (limited to 'honey/shader.lua')
-rw-r--r--honey/shader.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/honey/shader.lua b/honey/shader.lua
index 1fb9f5b..083b260 100644
--- a/honey/shader.lua
+++ b/honey/shader.lua
@@ -15,11 +15,26 @@ local function compileShader(source, type)
return shader
end
+local function readFile(filename)
+ local f, err = io.open(filename)
+ if not f then error(err) end
+ local str = f:read("*a")
+ f:close()
+ return str
+end
+
function Shader.new(_, sources)
local self = {}
self.locations = {}
self.links = {}
+ if sources.vertexFile then
+ sources.vertex = readFile(sources.vertexFile)
+ end
+ if sources.fragmentFile then
+ sources.fragment = readFile(sources.fragmentFile)
+ end
+
local shaders = {}
if sources.vertex then
table.insert(shaders, compileShader(sources.vertex, gl.VERTEX_SHADER))