Page 8 of 23

Re: Love.js - A Direct Emscripten Port

Posted: Thu Apr 14, 2016 8:16 pm
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.

Re: Love.js - A Direct Emscripten Port

Posted: Fri Apr 15, 2016 1:29 am
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.

Re: Love.js - A Direct Emscripten Port

Posted: Sat Apr 23, 2016 4:28 pm
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

Re: Love.js - A Direct Emscripten Port

Posted: Sat Oct 15, 2016 3:04 pm
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.

Re: Love.js - A Direct Emscripten Port

Posted: Sat Oct 15, 2016 4:18 pm
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.

Re: Love.js - A Direct Emscripten Port

Posted: Sat Oct 15, 2016 9:22 pm
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.

Re: Love.js - A Direct Emscripten Port

Posted: Sat Oct 15, 2016 10:01 pm
by Tanner
I'd like to! That's probably an entire day of work, realistically, so it's gonna be a little bit.

Re: Love.js - A Direct Emscripten Port

Posted: Wed Nov 23, 2016 5:39 pm
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

Re: Love.js - A Direct Emscripten Port

Posted: Wed Jan 18, 2017 7:55 am
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

Re: Love.js - A Direct Emscripten Port

Posted: Wed Jan 18, 2017 3:49 pm
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.