From 890c01a8bdc908298a31fa3e1061531f24cdb164 Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Mon, 8 Jun 2026 14:41:38 +0200 Subject: [PATCH] first steps to add LOVE support --- README.md | 43 +++++++++++++++++++++++++++++++------------ src/conf.lua | 12 +++++++++--- src/love/conf.lua | 5 +++++ src/love/main.lua | 17 +++++++++++++++++ src/main.lua | 11 +++++++---- src/util.lua | 2 +- 6 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 src/love/conf.lua create mode 100644 src/love/main.lua diff --git a/README.md b/README.md index 1a7a057..332e2da 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,36 @@ +## Usage -## Install +Download/run the binaries for your platform in the releases section.
+Developers can run it via [LÖVR](https://lovr.org) or [LÖVE2D](https://love2d.org) -Make sure to [download the loVR runtime](https://lovr.org/downloads) and drag -the `src`-folder of this repository to the **lovr** application [as described in the docs](https://lovr.org/downloads) - -If you already have lovr installed, you can run this in your console as well: ``` +$ love src # if you have LÖVE2D installed (>v12) +$ lovr src # if you have LÖVR installed +``` + +## Multiplatform + +The aim of this project is providing **one [XR Hypermedia browser](https://xrhf.isvery.ninja) codebase** which gracefully degrades between: + +* mac/win/linux/android via [LÖVE2D](https://love2d.org) +* mac/win/linux/android via [LÖVR](https://lovr.org) +* Web (2D) via [love.js](https://github.com/Davidobot/love.js) +* Nintendo 3DS, Switch, and Wii via [lovebrew](https://lovebrew.org/) +* Handhelds: Steamdeck, Anbernic, Gameforce, Game Kiddy, Powkiddy (..and more) via [portmaster](https://portmaster.games/supported-devices.html) +* Game emulators via [lutro](https://lutro.libretro.com/) +* Embedded devices via lua and/oror [nelua](https://nelua.org) + +## Ultra-hackable Extensions + +* XURFER does everything via browser extensions.
+* XURFER is the total sum of browser extensions.
+ +So you can strip/bloat however you want, or build one yourself: + +``` +$ cp src/ext/skeleton src/ext/myextension +$ sed 's|skeleton|myextension|g' src/ext/myextension/* $ ./lovr src +[i] loading 'myextension' +... ``` - -or nix: - -``` -$ appimage-run ./lovr src -``` - diff --git a/src/conf.lua b/src/conf.lua index 01f1b48..ac743fb 100644 --- a/src/conf.lua +++ b/src/conf.lua @@ -1,8 +1,14 @@ +-- sync lovr/love positional cli arguments +if arg[0] == nil and arg[1] ~= nil then arg[0] = arg[1] end + package.path = package.path .. ';' .. arg[0] .. '/lovr/?.lua;' .. arg[0] .. '/lovr/?/init.lua;' .. arg[0] .. '/lib/?.lua' -if lovr ~= nil then - require("lovr/conf") -end +local runtime = "" + +if lovr ~= nil then runtime = "lovr" end +if love ~= nil then runtime = "love" end + +require( runtime .. "/conf") diff --git a/src/love/conf.lua b/src/love/conf.lua new file mode 100644 index 0000000..48bb661 --- /dev/null +++ b/src/love/conf.lua @@ -0,0 +1,5 @@ +function love.conf(t) + t.window.width = 1024 + t.window.height = 720 + t.window.title = "X U R F Ξ R" +end diff --git a/src/love/main.lua b/src/love/main.lua new file mode 100644 index 0000000..2827769 --- /dev/null +++ b/src/love/main.lua @@ -0,0 +1,17 @@ +-- Load some default values for our rectangle. +function love.load() + x, y, w, h = 20, 20, 60, 20 +end + +-- Increase the size of the rectangle every frame. +function love.update(dt) + w = w + 1 + h = h + 1 +end + +-- Draw a coloured rectangle. +function love.draw() + -- In versions prior to 11.0, color component values are (0, 102, 102) + love.graphics.setColor(0, 0.4, 0.4) + love.graphics.rectangle("fill", x, y, w, h) +end diff --git a/src/main.lua b/src/main.lua index 76c1fce..37cd572 100644 --- a/src/main.lua +++ b/src/main.lua @@ -5,15 +5,15 @@ api = { browser = require("browser"), url = require("url"), util = require("util"), - protocol = { - http = require('http') - }, ecs = require("tiny-ecs"), ext = {}, -- all extensions loaded from disk at runtime exec = function(...) util.exec(...) end -- calls function on each table item } if lovr ~= nil then api = util.merge( api, lovr ) + api['protocol'] = { + http = require('http') + }, util.loaddir( "ext", api, api.ext ) util.loaddir( "media", api, api.media ) require("lovr/main") @@ -23,4 +23,7 @@ end local url='https://coderofsalvation.codeberg.page/xrfragment-haxe/example/assets/example.glb?bar=1&f=2#foo' --local url = 'https://codeberg.org/coderofsalvation/xrfragment/raw/branch/main/assets/template/website/website.glb' --local url = 'https://codeberg.org/coderofsalvation/xrfragment/raw/branch/main/assets/simple-a.glb' -api.browser.to(url) + +if lovr ~= nil then -- TODO: make this work for LOVE2D too + api.browser.to(url) +end diff --git a/src/util.lua b/src/util.lua index da0979c..c12167b 100644 --- a/src/util.lua +++ b/src/util.lua @@ -5,7 +5,7 @@ util.loaddir = function( path, api, target) foreach( dir, function(k,v) local ext = path .. '/' .. v .. "/main.lua" if api.filesystem.isFile(ext) then - print("[i] found extension '" .. v .. "'") + print("[i] loading '" .. v .. "'") target[ v ] = api.filesystem.load( ext )(api) end end)