Skip to content

Commit a71aff9

Browse files
committed
Made light.glsl GL_ES compatible.
1 parent 69df939 commit a71aff9

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

circle-amongst-squares/light.glsl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Source of the light in screen coordinates
2-
extern vec2 sourcePos = vec2(0, 0);
2+
extern vec2 sourcePos;
33

44
number dist(vec2 pos1, vec2 pos2) {
55
return (pos1.x - pos2.x) * (pos1.x - pos2.x) +
@@ -10,17 +10,17 @@ vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords){
1010
vec4 pixel = Texel(texture, texture_coords);
1111
number distance = dist(sourcePos, screen_coords);
1212

13-
if (distance > 10000) {
14-
pixel.r = 0;
15-
pixel.g = 0;
16-
pixel.b = 0;
13+
if (distance > 10000.0) {
14+
pixel.r = 0.0;
15+
pixel.g = 0.0;
16+
pixel.b = 0.0;
1717
}
1818
// For some reason this doesn't cause problems
1919
// even if distance is 0...
2020
else {
21-
pixel.r *= 1000 / distance;
22-
pixel.g *= 1000 / distance;
23-
pixel.b *= 1000 / distance;
21+
pixel.r *= 1000.0 / distance;
22+
pixel.g *= 1000.0 / distance;
23+
pixel.b *= 1000.0 / distance;
2424
}
2525
return pixel * color;
2626
}

circle-amongst-squares/main.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function love.load()
7575
movesound = love.audio.newSource("res/movement.ogg", "static")
7676
next_move_in = love.math.random(10, 20)
7777

78-
light = love.graphics.newShader("light.glsl")
7978
world = bump.newWorld()
8079
squares = {}
8180
circle = {x=0, y=0, dx=0, dy=0, speed=100, r=10, color={1, 1, 1, 1}}
@@ -87,6 +86,7 @@ function love.load()
8786
world:add(square, square.x, square.y, square.width, square.height)
8887
end
8988

89+
light = love.graphics.newShader("light.glsl")
9090
light:send("sourcePos", {circle.x + circle.r, circle.y + circle.r})
9191
end
9292

0 commit comments

Comments
 (0)