Skip to content
Snippets Groups Projects
Commit 6d083bcb authored by DarkGod's avatar DarkGod
Browse files

test outline

parent d97fb86e
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,15 @@
require "engine.class"
require "engine.ui.Base"
local Shader = require "engine.Shader"
local Mouse = require "engine.Mouse"
local Slider = require "engine.ui.Slider"
--- Module that handles message history in a mouse wheel scrollable zone
module(..., package.seeall, class.inherit(engine.ui.Base))
local shader = Shader.new("textoutline")
--- Creates the log zone
function _M:init(x, y, w, h, max, fontname, fontsize, color, bgcolor)
self.color = color or {255,255,255}
......@@ -54,7 +57,7 @@ function _M:enableShadow(v)
end
function _M:enableFading(v)
self.fading = v
-- self.fading = v
end
--- Resize the display area
......@@ -243,8 +246,15 @@ function _M:toScreen()
end
self.dlist[i].dh = h
if self.shadow then item._tex:toScreenFull(self.display_x+2, h+2, item.w, item.h, item._tex_w, item._tex_h, 0,0,0, self.shadow * fade) end
if self.shadow then
if shader.shad then
shader.shad:use(true)
else
item._tex:toScreenFull(self.display_x+2, h+2, item.w, item.h, item._tex_w, item._tex_h, 0,0,0, self.shadow * fade)
end
end
item._tex:toScreenFull(self.display_x, h, item.w, item.h, item._tex_w, item._tex_h, 1, 1, 1, fade)
if self.shadow and shader.shad then shader.shad:use(false) end
for di = 1, #item._dduids do item._dduids[di].e:toScreen(nil, self.display_x + item._dduids[di].x, h, item._dduids[di].w, item._dduids[di].w, fade, false, false) end
h = h - self.fh
end
......
uniform sampler2D tex;
uniform vec2 textSize;
uniform vec4 outlineColor;
void main(void)
{
vec2 off = 1.0 / textSize;
vec2 tc = gl_TexCoord[0].st;
vec4 c = texture2D(tex, tc);
vec4 n = texture2D(tex, vec2(tc.x, max(0.0, tc.y - off.y)));
vec4 e = texture2D(tex, vec2(min(1.0, tc.x + off.x), tc.y));
vec4 s = texture2D(tex, vec2(tc.x, min(1.0, tc.y + off.y)));
vec4 w = texture2D(tex, vec2(min(0.0, tc.x - off.x), tc.y));
vec4 origColor = c * gl_Color;
float ua = 0.0;
ua = mix(ua, 1.0, c.a);
ua = mix(ua, 1.0, n.a);
ua = mix(ua, 1.0, e.a);
ua = mix(ua, 1.0, s.a);
ua = mix(ua, 1.0, w.a);
vec4 underColor = outlineColor * vec4(ua);
gl_FragColor = underColor;
gl_FragColor = mix(gl_FragColor, origColor, origColor.a);
gl_FragColor.a = max(sqrt(gl_FragColor.a / 2.0), c.a);
// if (gl_FragColor.r + gl_FragColor.g + gl_FragColor.b <= 0.0) gl_FragColor.a = 0.0;
gl_FragColor = texture2D(tex, gl_TexCoord[0].xy);
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ return {
args = {
tex = { texture = 0 },
textSize = textSize or {1, 1},
outlineColor = outlineColor or {0,0,0,0.4},
outlineColor = outlineColor or {1,0,0,0.8},
},
clone = false,
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment