diff options
author | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-18 12:07:48 -0400 |
---|---|---|
committer | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-18 12:07:48 -0400 |
commit | ec0ab456cf869f2daa6dea41158c54da745626d8 (patch) | |
tree | 85d9c23774ffee6d7608782dac3086e15e1efc90 | |
parent | 2cedd39a90fdb0387783b50446b16732517fb651 (diff) |
Added basic UI shaders
-rw-r--r-- | Scripts/init.lua | 8 | ||||
-rw-r--r-- | Shaders/ui.frag | 12 | ||||
-rw-r--r-- | Shaders/ui.vert | 14 |
3 files changed, 30 insertions, 4 deletions
diff --git a/Scripts/init.lua b/Scripts/init.lua index 84d2073..d76a402 100644 --- a/Scripts/init.lua +++ b/Scripts/init.lua @@ -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 index 0000000..737344e --- /dev/null +++ b/Shaders/ui.frag @@ -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 index 0000000..b2fcba4 --- /dev/null +++ b/Shaders/ui.vert @@ -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); +} |