diff options
author | sanine <sanine.not@pm.me> | 2022-08-22 10:31:56 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-22 10:31:56 -0500 |
commit | 65ad3a58adcfe21690f379ab894a104b3852e3e9 (patch) | |
tree | 2e86cb35d06b29ac98ca22c7eb6d051d4fde855b /demo | |
parent | f84ee69cdf694a1f64f2536efed4b7d0dd75553a (diff) |
refactor: move shader functions into separate file
Diffstat (limited to 'demo')
-rw-r--r-- | demo/honey.lua | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/demo/honey.lua b/demo/honey.lua index 15acbf2..0a4758a 100644 --- a/demo/honey.lua +++ b/demo/honey.lua @@ -46,19 +46,19 @@ void main() } ]] -local vertexShader = gl.createShader(gl.shaderType.vertexShader) -gl.setShaderSource(vertexShader, vertexShaderSource) -gl.compileShader(vertexShader) -local fragmentShader = gl.createShader(gl.shaderType.fragmentShader) -gl.setShaderSource(fragmentShader, fragmentShaderSource) -gl.compileShader(fragmentShader) +local vertexShader = gl.shader.create(gl.shader.type.vertexShader) +gl.shader.setSource(vertexShader, vertexShaderSource) +gl.shader.compile(vertexShader) +local fragmentShader = gl.shader.create(gl.shader.type.fragmentShader) +gl.shader.setSource(fragmentShader, fragmentShaderSource) +gl.shader.compile(fragmentShader) -local shader = gl.createProgram() -gl.programAttachShader(shader, vertexShader) -gl.programAttachShader(shader, fragmentShader) -gl.linkProgram(shader) -gl.deleteShader(vertexShader) -gl.deleteShader(fragmentShader) +local shader = gl.shader.createProgram() +gl.shader.attachShader(shader, vertexShader) +gl.shader.attachShader(shader, fragmentShader) +gl.shader.link(shader) +gl.shader.delete(vertexShader) +gl.shader.delete(fragmentShader) local vertices = { @@ -90,7 +90,7 @@ while not window.shouldClose(w) do gl.setClearColor(0.2, 0.3, 0.3, 1.0) gl.clear(gl.bufferMask.colorBuffer); - gl.useProgram(shader) + gl.shader.use(shader) gl.bindVertexArray(vertexArray) gl.drawArrays(gl.primitiveType.triangles, 0, 3) |