aboutsummaryrefslogtreecommitdiffstats
path: root/shaders
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-04-04 13:36:46 +0200
committerDavid Robillard <d@drobilla.net>2020-04-04 13:36:46 +0200
commit11800b6179458eb962cd1862e4053efd7f28c2f4 (patch)
tree1b239515e3c36e11c04b9da1861aa65eff0d6afd /shaders
parentecc281c56a8c3c297cfd2f0b6d4671b2000efd9b (diff)
downloadpugl-11800b6179458eb962cd1862e4053efd7f28c2f4.tar.gz
pugl-11800b6179458eb962cd1862e4053efd7f28c2f4.tar.bz2
pugl-11800b6179458eb962cd1862e4053efd7f28c2f4.zip
Shader Demo: Use a UBO
Diffstat (limited to 'shaders')
-rw-r--r--shaders/header_330.glsl2
-rw-r--r--shaders/rect.vert7
2 files changed, 7 insertions, 2 deletions
diff --git a/shaders/header_330.glsl b/shaders/header_330.glsl
index 5ae7f43..1bcdf05 100644
--- a/shaders/header_330.glsl
+++ b/shaders/header_330.glsl
@@ -1 +1,3 @@
#version 330 core
+
+#define UBO(qualifiers) layout(std140)
diff --git a/shaders/rect.vert b/shaders/rect.vert
index 337f105..ef8c8cc 100644
--- a/shaders/rect.vert
+++ b/shaders/rect.vert
@@ -1,7 +1,10 @@
/* The vertex shader is trivial, but forwards scaled UV coordinates (in pixels)
to the fragment shader for drawing the border. */
-uniform mat4 u_projection;
+UBO(binding = 0) uniform UniformBufferObject
+{
+ mat4 projection;
+} ubo;
layout(location = 0) in vec2 v_position;
layout(location = 1) in vec2 v_origin;
@@ -22,7 +25,7 @@ main()
v_origin[0], v_origin[1], 0.0, 1.0);
// clang-format on
- mat4 MVP = u_projection * m;
+ mat4 MVP = ubo.projection * m;
f_uv = v_position * v_size;
f_size = v_size;