## push - a resolution-handling library

bkwrm
Prole
Posts: 6
Joined: Mon Mar 07, 2016 10:51 pm

### Re: push: a resolution-handling library

Thank you for this, screen resolution handling is always the biggest headache for me when starting a new language (2 weeks in atm). I do have one question though, how would I go about enabling msaa, vsync, and the like?

The normal method ...sort of works:

Code: Select all

realWidth, realHeight = love.graphics.getDimensions( )
love.window.setMode(realWidth,realHeight,{vsync=true,msaa=8})
But results in you being able to see a sliver of title bar of the window, and also needs be called/set each time I use any of your screen functions since I'm overriding your work with it.

Since I'm still new to this and might not be fully understanding some of the inner workings of your library, just adding it into your function wouldn't cause any other problems I'm just not noticing right? I mean, I can't even tell when msaa is working anyways since I'm just using basic temp art like squares and ovals right now XD

Code: Select all

function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, f, vsync, msaa)
love.window.setMode( self._RWIDTH, self._RHEIGHT, {fullscreen = self._fullscreen, borderless = false, resizable = self._resizable, vsync=self.vsync,msaa=self.msaa} )

Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

### Re: push: a resolution-handling library

bkwrm wrote:Thank you for this, screen resolution handling is always the biggest headache for me when starting a new language (2 weeks in atm). I do have one question though, how would I go about enabling msaa, vsync, and the like?

Since I'm still new to this and might not be fully understanding some of the inner workings of your library, just adding it into your function wouldn't cause any other problems I'm just not noticing right? I mean, I can't even tell when msaa is working anyways since I'm just using basic temp art like squares and ovals right now XD

Code: Select all

function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, f, vsync, msaa)
love.window.setMode( self._RWIDTH, self._RHEIGHT, {fullscreen = self._fullscreen, borderless = false, resizable = self._resizable, vsync=self.vsync,msaa=self.msaa} )
Yup, you've got it right! You can totally add new parameters to the library.

An even simplier way to do that would be (from the original function):

Code: Select all

function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, f)

f = f or {}

self._WWIDTH, self._WHEIGHT = WWIDTH, WHEIGHT
self._RWIDTH, self._RHEIGHT = RWIDTH, RHEIGHT
self._fullscreen = f.fullscreen or self._fullscreen or  false
self._resizable = f.resizable or self._resizable or false
self._vsync = f.vsync or self._vsync or false
self._msaa = f.msaa or self._msaa or false
--

love.window.setMode( self._RWIDTH, self._RHEIGHT, {
fullscreen = self._fullscreen,
borderless = false,
resizable = self._resizable,
vsync = self._vsync,
msaa = self._msaa
--
} )

Where "f" is the params table.

You'd use it like so:

Code: Select all

push:setupScreen( WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, {
fullscreen = true,
vsync = true,
msaa = true,
resizable = false,
borderless = false
} )

for instance.

bkwrm
Prole
Posts: 6
Joined: Mon Mar 07, 2016 10:51 pm

### Re: push: a resolution-handling library

Oh wow thanks, I will probably convert over to that. Right now I've just copy pasted your function over and made my edits, this will neaten the code a bit.

Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

### Re: push: a resolution-handling library

Hello there!

With the Lowrez Jam coming up, I just couldn't ignore the opportunity to add a simple low-resolution example to push.

-Fixed push:toGame()

https://github.com/Ulydev/push

Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Hey everyone!

Nope, this is still not dead. I'm using this library in all of my games, and I'm adding new features as I work with it.

Recently I've been working on a game that wouldn't run well on mobile devices, and after figuring out it was because of canvases, I decided to add an option to disable them in push.

You can now provide a

Code: Select all

canvas = false
flag in push:setupScreen(...) to disable canvases.

Kibita
Prole
Posts: 31
Joined: Tue Dec 29, 2015 7:46 pm

### Re: push - a resolution-handling library

Hey!

The library is great! But I'd like to know if it's possible to use Push and Hump Camera at the same time, I mean: I want to use Push to the game resolution and Hump Camera for camera effects (movement, shake, etc...).
If you wanna go further with Push, take a look at Libgdx Camera/Viewport system. I really like how Libgdx implements its cameras, so, if you update Push like that for Love2D it would be great, imo.

Daniel Eakins
Citizen
Posts: 99
Joined: Thu Jul 18, 2013 9:14 pm
Location: France

Ulydev wrote:Hey everyone!

Nope, this is still not dead. I'm using this library in all of my games, and I'm adding new features as I work with it.

Recently I've been working on a game that wouldn't run well on mobile devices, and after figuring out it was because of canvases, I decided to add an option to disable them in push.

You can now provide a

Code: Select all

canvas = false
flag in push:setupScreen(...) to disable canvases.
The downside when disabling canvases is that some graphics, like the geometric shapes generated by love.graphics, no longer show up with the right scaled resolution (they're shown with the desktop resolution instead).

Also, you should probably put some math.floor in your divisions otherwise there is a possibility that the user ends up with scaling with floating-point numbers, in which case the graphics will not look good due to incorrect aspect ratio.

Teraku
Prole
Posts: 27
Joined: Mon Jun 24, 2013 10:01 am
Location: The Netherlands

### Re: push - a resolution-handling library

This is really useful!

How does this work with HUMP's Gamestate library, exactly? Do I call push:apply("start") and push:apply("end") in every gamestate's draw function?

Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

### Re: push - a resolution-handling library

Teraku wrote:This is really useful!

How does this work with HUMP's Gamestate library, exactly? Do I call push:apply("start") and push:apply("end") in every gamestate's draw function?
I'm not exactly sure how it works but you should be able to do something like this:

Code: Select all

function love.draw()
push:apply("start")
gamestate.draw()
push:apply("end")
end


Teraku
Prole
Posts: 27
Joined: Mon Jun 24, 2013 10:01 am
Location: The Netherlands

### Re: push - a resolution-handling library

Ulydev wrote:
Teraku wrote:This is really useful!

How does this work with HUMP's Gamestate library, exactly? Do I call push:apply("start") and push:apply("end") in every gamestate's draw function?
I'm not exactly sure how it works but you should be able to do something like this:

Code: Select all

function love.draw()
push:apply("start")
gamestate.draw()
push:apply("end")
end

That seems to work, but only if you don't call Gamestate.registerEvents(). Using push:apply() in the gamestate's draw functions seems to do the trick as well, but that would mean adding 2 lines of code for every gamestate.

So it's kind of a compromise between two extra lines in every gamestate, or not having HUMP handle your callbacks. But that's fine, it only takes a few seconds either way. I ended up doing the same thing as in your example.

I must say I'm very pleased with the results, it scales pretty well!

### Who is online

Users browsing this forum: No registered users and 21 guests