Page 1 of 1

Android portrait screen orientation & vertex shader error

Posted: Sun Apr 26, 2020 8:46 pm
by mrdar1us
Hello,
I have developed game and now i want to test it on android. I followed this guide: https://love2d.org/wiki/Game_Distribution/APKTool to build an apk file. Everything is working fine, but i can't change screen orientation to portrait. I tried to change

Code: Select all

 android:screenOrientation="sensorLandscape" 
to portrait and sensorPortrait, but still game is running in landscape orientation. How to fix that problem?

I have noticed that game is not running on one of mine devices. I'm getting error: boot.lua:535 "cannot compile vertex shader". Why I'm getting that error, if on other devices/emulators game works fine?

Thank you.

P.S: phone is Samsung Galaxy Core Prime, Android 5.1.1

Re: Android portrait screen orientation & vertex shader error

Posted: Mon Apr 27, 2020 6:52 am
by pgimeno
I can't answer your first question, but as for the second, GLSL compilation is performed by the graphics driver, so it seems the driver in that phone is stricter in what it accepts. Without a more detailed error message, it's hard to know what may have gone wrong.

Re: Android portrait screen orientation & vertex shader error

Posted: Mon Apr 27, 2020 9:26 am
by Andlac028
Are you resizing or setting windows width/height? (in conf.lua or by love.window module?) Because you can change screen orientation by setting window width & height (if width>height -> landscape; height>width -> portrait) if I'm not wrong

Re: Android portrait screen orientation & vertex shader error

Posted: Mon Apr 27, 2020 6:44 pm
by mrdar1us
Thank you for your replies!

Full error code:

Code: Select all

Error

boot.lua:535: Cannot compile vertex shader code:
(73:0) : error : invalid type field for default precision statement
(74:0) : error : invalid type field for default precision statement

Traceback

[C]: in function 'setMode'
[C]: in function 'xpcall'
[C]: in function 'xpcall'
Can it be a hardware issue? Because as I said before, I have tested on other devices, it works fine.

About window settings: I use this code in main.lua

Code: Select all


if love.system.getOS() == "Android" then
        local x, y = love.graphics.getDimensions()
        scalex = (x/windowWidth)
        scaley = (y/windowHeight)
    else
        scalex = 1
        scaley = scalex
    end
    love.window.setMode(windowWidth*scalex,windowHeight*scaley, {fullscreen = false})


Re: Android portrait screen orientation & vertex shader error

Posted: Mon Apr 27, 2020 8:25 pm
by pgimeno
mrdar1us wrote: Mon Apr 27, 2020 6:44 pm Full error code:

Code: Select all

Error

boot.lua:535: Cannot compile vertex shader code:
(73:0) : error : invalid type field for default precision statement
(74:0) : error : invalid type field for default precision statement

Hmm, that might be related to the use of integers where floats are expected. If there is a constant like 1, change it to 1.0. Or 5 -> 5.0 or... you get the idea.

It could also be related to the version. I believe that Löve inserts some precision statements and that may be related. Try including:

Code: Select all

#pragma language glsl3
somewhere near the top of the shader and see if that makes a difference.
mrdar1us wrote: Mon Apr 27, 2020 6:44 pm Can it be a hardware issue? Because as I said before, I have tested on other devices, it works fine.
Definitively not a hardware issue. Some drivers are more tolerant about what they accept than others, and some drivers are broken in that they claim to support certain features but they actually don't.

Just in case, can you show the shader?

Re: Android portrait screen orientation & vertex shader error

Posted: Tue Apr 28, 2020 4:05 pm
by mrdar1us
I'm noob in love2d, so I use default shader. According to love2d docs:

Code: Select all

local pixelcode = [[
    vec4 effect( vec4 color, Image tex, vec2 texture_coords, vec2 screen_coords )
    {
        vec4 texcolor = Texel(tex, texture_coords);
        return texcolor * color;
    }
]]
 
local vertexcode = [[
    vec4 position( mat4 transform_projection, vec4 vertex_position )
    {
        return transform_projection * vertex_position;
    }
]]

Re: Android portrait screen orientation & vertex shader error

Posted: Wed Apr 29, 2020 9:55 am
by pgimeno
Have you tried adding the line above?

Re: Android portrait screen orientation & vertex shader error

Posted: Sun Apr 18, 2021 3:16 am
by AuahDark
Not sure if it's gonna fix the "boot.lua" error, but can you try the APK in here? https://github.com/love2d/love-android/issues/204