use GLSL shaders

This commit is contained in:
Eduardo Bart
2011-12-06 22:31:55 -02:00
parent cf0aab6d4d
commit 7eead50806
64 changed files with 1219 additions and 630 deletions

View File

@@ -1,4 +1,3 @@
-- AnchorEdge
AnchorNone = 0
AnchorTop = 1
AnchorBottom = 2
@@ -15,9 +14,6 @@ LogFatal = 4
ActiveFocusReason = 2
EmptyFunction = function() end
-- KeyCodes
KeyUnknown = 0
KeyEscape = 1
KeyTab = 2
@@ -57,7 +53,7 @@ KeyLeftParen = 40 -- (
KeyRightParen = 41 -- )
KeyAsterisk = 42 -- *
KeyPlus = 43 -- +
KeyComma = 44 --
KeyComma = 44 -- ,
KeyMinus = 45 -- -
KeyPeriod = 46 -- .
KeySlash = 47 -- /

View File

@@ -7,10 +7,14 @@ Module
onLoad: |
require 'ext/table'
require 'ext/string'
require 'constants'
require 'util/point'
require 'util/size'
require 'util/color'
require 'util/rect'
require 'const'
require 'util'
require 'dispatcher'
require 'widget'
require 'ui'
require 'gfx'
require 'effects'
return true

View File

@@ -1,43 +1,33 @@
local eventId = 0
local eventsTable = { }
local orig = { scheduleEvent = scheduleEvent,
addEvent = addEvent }
local eventList = {}
-- fix original scheduleEvent
function scheduleEvent(func, delay)
eventId = eventId + 1
local id = eventId
local function proxyFunc()
if eventsTable[id] then
func()
eventsTable[id] = nil
if eventList[id] then
if eventList[id].active then
func()
end
eventList[id] = nil
end
end
eventsTable[id] = proxyFunc
orig.scheduleEvent(proxyFunc, delay)
eventList[id] = { func = proxyFunc, active = true }
if delay and delay > 0 then
g_dispatcher.scheduleEvent(proxyFunc, delay)
else
g_dispatcher.addEvent(proxyFunc, false)
end
return id
end
-- FIXME: the event function can be collected
-- and the dispatcher would call an invalid function, generating an warning
function addEvent(func)
return scheduleEvent(func, 0)
end
function removeEvent(id)
if id and eventsTable[id] then
eventsTable[id] = nil
if id and eventList[id] then
eventList[id].active = false
return true
end
end
-- fix original addEvent
function addEvent(func)
eventId = eventId + 1
local id = eventId
local function proxyFunc()
if eventsTable[id] then
func()
eventsTable[id] = nil
end
end
eventsTable[id] = proxyFunc
orig.addEvent(proxyFunc)
return id
end

View File

@@ -1,6 +1,6 @@
GFX = { }
Effects = {}
function GFX.fadeIn(widget, time, elapsed)
function Effects.fadeIn(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity(math.min((255*elapsed)/time, 255))
@@ -11,7 +11,7 @@ function GFX.fadeIn(widget, time, elapsed)
end
end
function GFX.fadeOut(widget, time, elapsed)
function Effects.fadeOut(widget, time, elapsed)
if not elapsed then elapsed = 0 end
if not time then time = 250 end
widget:setOpacity((255*(time - elapsed))/time)

View File

@@ -13,12 +13,12 @@ function string:starts(start)
return self:sub(1, #start) == start
end
function string.trim(str)
return str:match'^%s*(.*%S)' or ''
function string:trim()
return self:match('^%s*(.*%S)') or ''
end
function toboolean(str)
str = string.trim(str)
str = str:trim()
if str == '1' or str == 'true' then
return true
end

View File

@@ -1,7 +1,7 @@
function table.dump(t, depth)
if not depth then depth = 0 end
for k,v in pairs(t) do
str = string.rep(' ', depth * 2) .. k .. ': '
str = (' '):rep(depth * 2) .. k .. ': '
if type(v) ~= "table" then
print(str .. tostring(v))
else

View File

@@ -6,10 +6,8 @@ function print(...)
Logger.log(LogInfo, msg)
end
function createEnvironment()
local env = { }
setmetatable(env, { __index = _G} )
return env
function fatal(msg)
Logger.log(LogFatal, msg)
end
function connect(object, signalsAndSlots, pushFront)
@@ -28,10 +26,10 @@ function connect(object, signalsAndSlots, pushFront)
end
end
function dumpWidgets()
for i=1,UI.root:getChildCount() do
print(UI.root:getChildByIndex(i):getId())
end
function createEnvironment()
local env = { }
setmetatable(env, { __index = _G} )
return env
end
function getCallingScriptSourcePath(depth)

View File

@@ -16,4 +16,4 @@ function UIWidget:setMargin(...)
self:setMarginBottom(params[3])
self:setMarginLeft(params[4])
end
end
end