Skip to content

Commit

Permalink
Add shader asset type
Browse files Browse the repository at this point in the history
  • Loading branch information
polypoyo authored and NyakoFox committed Nov 6, 2024
1 parent 6de5383 commit f220681
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/engine/assets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ local self = Assets
---@field font_settings table<string, table>
---@field sound_data table<string, love.SoundData>
---@field music table<string, string>
---@field shaders table<string, string>
---@field videos table<string, string>
---@field bubble_settings table<string, table>

Expand Down Expand Up @@ -430,6 +431,10 @@ function Assets.newVideo(video, load_audio)
return love.graphics.newVideo(self.data.videos[video], {audio = load_audio})
end

function Assets.newShader(id)
return love.graphics.newShader(self.data.shaders[id])
end

Assets.clear()

return Assets
8 changes: 8 additions & 0 deletions src/engine/loadthread.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function resetData()
sound_data = {},
music = {},
videos = {},
shaders = {},
bubble_settings = {},
}
}
Expand All @@ -83,6 +84,7 @@ function resetData()
["sprites"] = {},
["fonts"] = {},
["sounds"] = {},
["shaders"] = {},
["music"] = {},
["videos"] = {},
["bubbles"] = {},
Expand Down Expand Up @@ -337,6 +339,12 @@ local loaders = {
data.assets.music[id] = full_path
end
end },
["shaders"] = { "assets/shaders", function (base_dir, path, full_path)
local id = checkExtension(path, "glsl")
if id then
data.assets.shaders[id] = full_path
end
end },
["videos"] = { "assets/videos", function (base_dir, path, full_path)
local id = checkExtension(path, "ogg", "ogv")
if id then
Expand Down

0 comments on commit f220681

Please sign in to comment.