summaryrefslogtreecommitdiff
path: root/demo
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-08-22 12:39:51 -0500
committersanine <sanine.not@pm.me>2022-08-22 12:39:51 -0500
commitb2c0dd12d2a39e74f8e6d63bffec073ef0871ea7 (patch)
tree743d7981669e242898af107871c41f65ee7d75ac /demo
parent249833947ff691dd79453c4d817387a6922236d6 (diff)
add uniforms
Diffstat (limited to 'demo')
-rw-r--r--demo/honey.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/demo/honey.lua b/demo/honey.lua
index 2b1759f..470880d 100644
--- a/demo/honey.lua
+++ b/demo/honey.lua
@@ -26,23 +26,21 @@ end)
local vertexShaderSource = [[
#version 330 core
layout (location = 0) in vec3 aPos;
-out vec3 pos;
void main()
{
gl_Position = vec4(aPos.x, aPos.y, aPos.z, 1.0);
- pos = aPos;
}
]]
local fragmentShaderSource = [[
#version 330 core
-in vec3 pos;
+uniform vec4 color;
out vec4 FragColor;
void main()
{
- FragColor = vec4(pos.x+0.5, 0.0f, 2*(pos.y+pos.x), 1.0f);
+ FragColor = color;
}
]]
@@ -100,8 +98,12 @@ while not window.shouldClose(w) do
gl.draw.clear(gl.draw.bufferMask.colorBuffer);
gl.shader.use(shader)
+ local time = window.getTime()
+ local greenValue = (math.sin(time) / 2) + 0.5
+ local colorLocation = gl.shader.getUniformLocation(shader, 'color')
+ gl.shader.uniform4f(colorLocation, 0, greenValue, 0, 1)
+
gl.data.bindVertexArray(vertexArray)
- --gl.draw.drawArrays(gl.draw.primitiveType.triangles, 0, 3)
gl.draw.drawElements(gl.draw.primitiveType.triangles, 6, gl.dataType.uint, 0)
window.swapBuffers(w)