Page 3 of 9

Re: push: a resolution-handling library

Posted: Mon Mar 07, 2016 11:11 pm
by bkwrm
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} )

Re: push: a resolution-handling library

Posted: Tue Mar 08, 2016 5:01 pm
by Ulydev
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
  --[[ Add this part ]]--
  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,
    --[[ Add this part ]]--
    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.

Re: push: a resolution-handling library

Posted: Wed Mar 09, 2016 1:33 am
by bkwrm
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.

Re: push: a resolution-handling library

Posted: Fri Apr 01, 2016 7:08 pm
by Ulydev
Hello there!

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

Image

-Fixed push:toGame()
-Added push:getDimensions(), push:getWidth() and push:getHeight()

https://github.com/Ulydev/push

Re: push - game resolution and shaders made simple

Posted: Tue Jun 28, 2016 7:14 pm
by Ulydev
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.

Re: push - a resolution-handling library

Posted: Mon Jul 11, 2016 10:44 pm
by Kibita
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.

Re: push - game resolution and shaders made simple

Posted: Thu Sep 01, 2016 7:05 pm
by Daniel Eakins
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.

Re: push - a resolution-handling library

Posted: Wed Sep 07, 2016 9:19 am
by Teraku
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?

Re: push - a resolution-handling library

Posted: Wed Sep 07, 2016 2:47 pm
by Ulydev
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

Re: push - a resolution-handling library

Posted: Fri Sep 09, 2016 8:23 am
by Teraku
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!