Page 1 of 1

Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 3:02 pm
by RostakaGmfun
Hi there!
I am new to love2d, but a day of explorations proved that this engine is really cool. However, as I am Linux user (specifically Debian Wheezy with Openbox DE) I have experienced fullscreen issue (I guess you've heard of it, linux users, don't you?). It is obvious that the bug comes from SDL library love2d depends on (I have tried to write simple game engine and faced the same thing some time ago). However, there is certainly a way to overcome it.
1) I am interested how can I set fullscreen mode without changing screen resolution in conf.lua file
2) A good idea is to implement so-called viewport scaling, so that you can choose game resolution whatever is the best fit for your needs, but the screen resolution would remain native.
I am interested to hear you opinions and see how many there are linux users who develop with love2d.
Best regards,
RostakaGmfun

Re: Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 3:35 pm
by BluBillz
one way i learned how to make fullscreen scale properly and look fancy how you want it is with a function like this..

Code: Select all

function checkResolution()
		if fullscreen == false then
			love.graphics.setMode(0, 0, false, v, f)
			love.graphics.setMode(love.graphics.getWidth() - 200,love.graphics.getHeight() - 200, false, v, f)
		end
		if fullscreen == true then
			love.graphics.setMode(0, 0, true, v, f)
			love.graphics.setMode(love.graphics.getWidth(),love.graphics.getHeight(), true, v, f)
		end
end
but for this to work with linux exactly who knows...you can try this out tho.

Re: Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 3:39 pm
by s-ol
RostakaGmfun wrote:Hi there!
I am new to love2d, but a day of explorations proved that this engine is really cool. However, as I am Linux user (specifically Debian Wheezy with Openbox DE) I have experienced fullscreen issue (I guess you've heard of it, linux users, don't you?). It is obvious that the bug comes from SDL library love2d depends on (I have tried to write simple game engine and faced the same thing some time ago). However, there is certainly a way to overcome it.
1) I am interested how can I set fullscreen mode without changing screen resolution in conf.lua file
2) A good idea is to implement so-called viewport scaling, so that you can choose game resolution whatever is the best fit for your needs, but the screen resolution would remain native.
I am interested to hear you opinions and see how many there are linux users who develop with love2d.
Best regards,
RostakaGmfun
I'm on i3 on Arch with no issues.

For changing fullscreen mode at runtime, here's the API:
https://www.love2d.org/wiki/love.window

Re: Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 4:44 pm
by slime
RostakaGmfun wrote:Hi there!
I am new to love2d, but a day of explorations proved that this engine is really cool. However, as I am Linux user (specifically Debian Wheezy with Openbox DE) I have experienced fullscreen issue (I guess you've heard of it, linux users, don't you?). It is obvious that the bug comes from SDL library love2d depends on (I have tried to write simple game engine and faced the same thing some time ago). However, there is certainly a way to overcome it.
What kind of issue are you experiencing? exclusive-fullscreen mode has drawbacks but they shouldn't manifest as bugs.
RostakaGmfun wrote:1) I am interested how can I set fullscreen mode without changing screen resolution in conf.lua file

Code: Select all

function love.conf(t)
    t.window.fullscreen = true
    t.window.fullscreentype = "desktop"
end
Or you can do it using [wiki]love.window.setMode[/wiki]:

Code: Select all

function love.load()
    love.window.setMode(800, 600, {fullscreen = true, fullscreentype = "desktop"})
end
Or [wiki]love.window.setFullscreen[/wiki] if you want to toggle into and out of fullscreen:

Code: Select all

function love.keypressed(key)
    if key == "f" then
        love.window.setFullscreen(not love.window.getFullscreen(), "desktop")
    end
end
(see the [wiki]FullscreenType[/wiki] wiki page.)

Re: Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 4:51 pm
by RostakaGmfun
S0lll0s wrote: I'm on i3 on Arch with no issues.

For changing fullscreen mode at runtime, here's the API:
https://www.love2d.org/wiki/love.window
Hm, interesting. On my system, If I change the resolution of love game and move mouse to the edge of the screen, the view will scroll and you will see other windows under the game window. What is most annoying thins is that when I tried to take screenshot of this, I actually got game window and black background at places where desktop is visible:
Image

Update
Just came up with the idea that mouse can be fixed at the center of the window, and the desktop will never be visible, because mouse will never reach the edge of the screen. I will try in a moment and tell how that was went on.

Re: Fullscreen in Linux issue

Posted: Fri Mar 06, 2015 5:31 pm
by RostakaGmfun
At last, I made that.
Here is example code:

Code: Select all

local screen = {}
screen.w = 800
screen.h = 600

local mouse = {}
mouse.x = screen.w/2
mouse.y = screen.h/2

function love.load()
    love.window.setMode(screen.w/2,screen.h/2,{fullscreen=true})
    love.graphics.setBackgroundColor(128,128,128)
    love.graphics.setColor(255,192,28)
    love.mouse.setX(0)
    love.mouse.setX(0)
    love.mouse.setY(screen.w/2)
    love.mouse.setY(screen.h/2)
end

function love.mousemoved(x, y, dx, dy)
    mouse.x = mouse.x+x-screen.w/2
    mouse.y = mouse.y+y-screen.h/2
    if mouse.x>screen.w
        then mouse.x = screen.w
    elseif mouse.x<0
        then mouse.x = 0
    end
    if mouse.y>screen.h
        then mouse.y = screen.h
    elseif mouse.y<0
        then mouse.y = 0
    end
    love.mouse.setX(screen.w/2)
    love.mouse.setY(screen.h/2)
end

function love.draw()
    love.graphics.print("mouse.x: "..mouse.x..",mouse.y: "..mouse.y, 10, 10)
    love.graphics.circle("fill", mouse.x,mouse.y, 10, 20)
end
Briefly, it sets screen resolution from screen table. Next it processes mouse move event in love.mousemoved(). Every time mouse is moved it is being put back at the center of the screen, and mouse table is updated with position of mouse. In love.draw() the mouse coordinates are printed and an orange circle is drawn at position (mouse.x,mouse.y). This way, you still get your mouse and fullscreen in Linux working perfectly. Please tell me if it works on your systems.
Hope somebody will find this useful.
Update
The only thing left is to hide real mouse cursor and draw nice cursor image instead of orange circle. Also, mouse sensitivity should be tweaked a bit.