]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Added basic UI shaders
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 18 Sep 2019 16:07:48 +0000 (12:07 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Wed, 18 Sep 2019 16:07:48 +0000 (12:07 -0400)
Scripts/init.lua
Shaders/ui.frag [new file with mode: 0644]
Shaders/ui.vert [new file with mode: 0644]

index 84d20731bf7ecc020c8b28f7eba97f00632ee0fe..d76a4020a4b121f3a7a7bb9d74a978a5d8a91088 100644 (file)
@@ -2,18 +2,18 @@ player = {
     Player = 0,
     EventListeners = {
         MoveLeftPressed = function(self)
-            self.Velocity.x = self.Velocity.x - 3
+            self.Velocity.x = self.Velocity.x - 3.0
             self.Render.flipx = true;
         end,
         MoveLeftReleased = function(self)
-            self.Velocity.x = self.Velocity.x + 3
+            self.Velocity.x = self.Velocity.x + 3.0
         end,
         MoveRightPressed = function(self)
-            self.Velocity.x = self.Velocity.x + 3
+            self.Velocity.x = self.Velocity.x + 3.0
             self.Render.flipx = false;
         end,
         MoveRightReleased = function(self)
-            self.Velocity.x = self.Velocity.x - 3
+            self.Velocity.x = self.Velocity.x - 3.0
         end,
         JumpKeyPressed = function(self)
             if self.Physics.standing == true then
diff --git a/Shaders/ui.frag b/Shaders/ui.frag
new file mode 100644 (file)
index 0000000..737344e
--- /dev/null
@@ -0,0 +1,12 @@
+uniform sampler2D sampler;
+
+varying vec2 texCoord;
+varying vec4 color;
+
+void main(){
+    vec4 pixelColor = texture2D(sampler, vec2(texCoord.x, texCoord.y));
+    //TODO allow antialiasing
+       //if (pixelColor.w != 1.0f)
+       //      discard;
+       gl_FragColor = pixelColor * color;
+}
diff --git a/Shaders/ui.vert b/Shaders/ui.vert
new file mode 100644 (file)
index 0000000..b2fcba4
--- /dev/null
@@ -0,0 +1,14 @@
+attribute vec3 coord2d;
+attribute vec2 tex_coord;
+
+uniform mat4 ortho;
+uniform vec4 tex_color;
+
+varying vec2 texCoord;
+varying vec4 color;
+
+void main(){
+    texCoord = tex_coord;
+    color = tex_color;
+    gl_Position = ortho * vec4(coord2d.xyz, 1.0);
+}