Love.js - A Direct Emscripten Port

Discuss any ports of LÖVE to different platforms.
User avatar
logorrhea
Prole
Posts: 6
Joined: Wed Jan 13, 2016 8:37 pm

Re: Love.js - A Direct Emscripten Port

Post by logorrhea »

Looks like there were 2 issues:

The harder-to-find issue was that it doesn't like the gammacorrect config option. Anytime I enable gammacorrect in the config file, it doesn't run properly.

The other more obvious issue was the way I was bringing in shader code. I had the code stored in .glsl files, and was reading them in via love.filesystem.read. When I just put the shader code inline, it works fine. Or, if I put the shader code in a .lua file that simply returns a string, and load the code via require, that also works.
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love.js - A Direct Emscripten Port

Post by Tanner »

logorrhea wrote:Looks like there were 2 issues:

The harder-to-find issue was that it doesn't like the gammacorrect config option. Anytime I enable gammacorrect in the config file, it doesn't run properly.

The other more obvious issue was the way I was bringing in shader code. I had the code stored in .glsl files, and was reading them in via love.filesystem.read. When I just put the shader code inline, it works fine. Or, if I put the shader code in a .lua file that simply returns a string, and load the code via require, that also works.
Good to know. Thanks for debugging! I'll look into those things.
User avatar
alberto_lara
Party member
Posts: 372
Joined: Wed Oct 30, 2013 8:59 pm

Re: Love.js - A Direct Emscripten Port

Post by alberto_lara »

alberto_lara wrote:Hey, I just tried to run this game but I get an error, any idea what could be wrong?

Image
This happened on Manjaro Linux, maybe an OpenGL/Graphics driver issue (since I had problems when seeing google maps in 3D mode), it works fine in Ubuntu MATE:

Image
popcade
Prole
Posts: 2
Joined: Wed Jun 08, 2016 3:42 pm

Re: Love.js - A Direct Emscripten Port

Post by popcade »

It seems the code was not updated for a while, if possible I hope it to be integrated into the official Love2D ports, as it seems to be stable enough and need not so much modification(compared to other HTML5 ports) to original code base.
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love.js - A Direct Emscripten Port

Post by Tanner »

With the current available technology, I'm of the opinion that this project will never be good enough to become one of the actual targeted platforms for Love. I have hope that advances in Web Assembly and shared memory threads in the browser will, in time, yield a more satisfactory result.

In the meantime, I still think that love.js is amazing. That a project as complex as Love can be compiled to javascript and work as well as it does is freaking magic. Enjoy it how it is and when the tech is there, believe me, I'll be the first person to push this forward.
User avatar
Sheepolution
Party member
Posts: 264
Joined: Mon Mar 04, 2013 9:31 am
Location: The Netherlands
Contact:

Re: Love.js - A Direct Emscripten Port

Post by Sheepolution »

Hey Tanner, do you think you can/plan to fix the page freezing when getting an error? It can be solved by removing the while loop in love.errhand, I believe.
User avatar
Tanner
Party member
Posts: 166
Joined: Tue Apr 10, 2012 1:51 am

Re: Love.js - A Direct Emscripten Port

Post by Tanner »

I'd like to! That's probably an entire day of work, realistically, so it's gonna be a little bit.
gianmichele
Citizen
Posts: 63
Joined: Tue Jan 14, 2014 11:03 pm

Re: Love.js - A Direct Emscripten Port

Post by gianmichele »

Hey guys, first of all great great job.

Has anyone looked into integrating some of the sdks that html5 portals require for publishing. Is it difficult? Not supported?

Thanks,
Gian
danvdragos
Prole
Posts: 2
Joined: Wed Jan 18, 2017 7:24 am

Re: Love.js - A Direct Emscripten Port

Post by danvdragos »

Thanks for love.js/love2d. I found it through picolove with the goal to scale my game from its pico8 prototype.

I found a simple solution to integrate REST APIs with love.js using stdin/stdout:

Code: Select all

//in index.html
var input="input"; var inputIdx=-1;
var Module = {
print: function(sout) { console.log('lua stdout: ' + sout) },
//[...]
preRun : [function() {
 function stdin() {
  ++inputIdx;
  if(inputIdx>input.length)
   return 0;
  return input[inputIdx].charCodeAt(0);
 }

Code: Select all

-- in main.lua
function love.load(arg)
 io.stdout:setvbuf("no")
 io.stdin:setvbuf("no")
 
 io.stdin:write("output")
 sinp=io.stdin:read(1)
 while sinp~=nil do
  sinp=io.stdin:read(1) end
end
Both setvbuf and read a single byte is required or it won't work. Now you can request javascript XHRs from lua.

If you use the release version you will need to preallocate more memory:

Code: Select all

//in index.html
var Module = {
 TOTAL_MEMORY:100000000, // 100MBs
Love.js is using lua 5.1 and is missing the bit module. You can use these functions instead:

Code: Select all

-- in main.lua
function bit_xor(a,b)
    local p,c=1,0
    while a>0 and b>0 do
        local ra,rb=a%2,b%2
        if ra~=rb then c=c+p end
        a,b,p=(a-ra)/2,(b-rb)/2,p*2
    end
    if a<b then a=b end
    while a>0 do
        local ra=a%2
        if ra>0 then c=c+p end
        a,p=(a-ra)/2,p*2
    end
    return c
end
function bit_or(a,b)
    local p,c=1,0
    while a+b>0 do
        local ra,rb=a%2,b%2
        if ra+rb>0 then c=c+p end
        a,b,p=(a-ra)/2,(b-rb)/2,p*2
    end
    return c
end
function bit_not(n)
    local p,c=1,0
    while n>0 do
        local r=n%2
        if r<1 then c=c+p end
        n,p=(n-r)/2,p*2
    end
    return c
end
function bit_and(a,b)
    local p,c=1,0
    while a>0 and b>0 do
        local ra,rb=a%2,b%2
        if ra+rb>1 then c=c+p end
        a,b,p=(a-ra)/2,(b-rb)/2,p*2
    end
    return c
end
function bit_lshift(a,n)
  return bit_and(a*2^n,4095)
end
function bit_lshift32(a,n)
  return bit_and(a*2^n,4294967295)
end
function bit_rshift(a,n)
  return math.floor(a/2^n)
end
function bit_bits(x)
    local powers={
        nil,nil,nil,nil,
        nil,nil,nil,nil,
        nil,nil,nil,nil,
        nil,nil,nil,nil,
    }
    local i,n=1,0
    while x~=0 do
        local r=x%2
        if r==1 then
            x,n=x-1,n+1
            powers[n]=i
        end
        x,i=x/2,2*i
    end
end
function bit_sum32(a,b)
return bit_and(a+b,4294967295)
end
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: Love.js - A Direct Emscripten Port

Post by Ulydev »

danvdragos wrote: I found a simple solution to integrate REST APIs with love.js using stdin/stdout:
Nice work! I'm kinda new to this, but do you think that could open the gate to luasockets? This feature is probably the only thing that prevents me from making my game with love.js. I'm currently making a multiplayer HTML5 game with Pixi.js but it's hella hard compared to LÖVE.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests