Android portrait screen orientation & vertex shader error

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
mrdar1us
Prole
Posts: 3
Joined: Sun Apr 26, 2020 8:15 pm

Android portrait screen orientation & vertex shader error

Post 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
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android portrait screen orientation & vertex shader error

Post 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.
Andlac028
Party member
Posts: 174
Joined: Fri Dec 14, 2018 2:27 pm
Location: Slovakia

Re: Android portrait screen orientation & vertex shader error

Post 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
mrdar1us
Prole
Posts: 3
Joined: Sun Apr 26, 2020 8:15 pm

Re: Android portrait screen orientation & vertex shader error

Post 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})

User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android portrait screen orientation & vertex shader error

Post 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?
mrdar1us
Prole
Posts: 3
Joined: Sun Apr 26, 2020 8:15 pm

Re: Android portrait screen orientation & vertex shader error

Post 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;
    }
]]
User avatar
pgimeno
Party member
Posts: 3541
Joined: Sun Oct 18, 2015 2:58 pm

Re: Android portrait screen orientation & vertex shader error

Post by pgimeno »

Have you tried adding the line above?
User avatar
AuahDark
Party member
Posts: 107
Joined: Mon Oct 23, 2017 2:34 pm
Location: Indonesia
Contact:

Re: Android portrait screen orientation & vertex shader error

Post 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
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 17 guests