Giter Site home page Giter Site logo

push's People

Contributors

geoffbeier avatar htv04 avatar mutableloss avatar sherjilozair avatar tesselode avatar ulydev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

push's Issues

push:toGame return value

Thank you for the code, it really saved time!

However I don't like getting nil back with push:toGame, so I added an alternate calculation. If method is true It should return 0 or the respective max game width/height instead.
Maybe you care to implement it?

function push:toGame(x, y, method)
  x, y = x - self._OFFSET.x, y - self._OFFSET.y
  local normalX, normalY = x / self._GWIDTH, y / self._GHEIGHT
  
  if method then
-- new version
    x = ( (x < 0 and 0 ) or 
        ( (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH ) or
            (x >=self._WWIDTH * self._SCALE.x and self._WWIDTH ) )
    y = ( (y < 0 and 0 ) or 
        ( (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT ) or
            (y >=self._WHEIGHT * self._SCALE.y and self._WHEIGHT ) )
  else
-- old code
    x = (x >= 0 and x <= self._WWIDTH * self._SCALE.x) and normalX * self._WWIDTH or nil
    y = (y >= 0 and y <= self._WHEIGHT * self._SCALE.y) and normalY * self._WHEIGHT or nil
  end
  
  return x, y
end

Properly scale love.graphics.circle?

I've got everything set up in my project to scale images and fonts properly, but I noticed today that love.graphics.circle and love.graphics.ellipse don't scale to the same pixel size as everything else. Is that a known bug/issue/design choice?

As an example, notice the gray circle in the top-left corner. Its pixels are about a third the size of the other pixels on screen.
screen shot 2018-11-22 at 3 12 27 pm

Black bars problem and windowed mode broken

Hello i am a game dev i am using Ulydev's Push Master its was really useful for my game development
but it has a issue,
Well there is the problem you see my game runs in 640x360 so i used the push master. My computer runs at a resolution of 1366x768
So when its in windowed mode pixel distorsion. i have already fixed that by replace the 0.5 window size by a 0.469 it got fixed
but when i was testing in 1280x720 with the modified 0.469 window size , its just give a black image , in 0.5 window size in 1280x720 the image was displaying , too in 1366x768 when i was setting in fullscreen my game blacks bars appears , but in 1280x720 No black bars.
Sorry if it is long.
Can you fix this Ulydev?

memory usage steadily increases when using canvases

If you run a main.lua with the following code:

local push = require 'push'

push:setupScreen(384, 216, 1280, 720)

function love.draw()
	push:start()
	love.graphics.print('Memory usage: ' .. math.floor(collectgarbage 'count') .. 'kb')
	push:finish()
end

The memory usage will steadily increase. This doesn't happen if canvases are disabled using {canvas = false}.

Setting window width/height to 0 in push:setupScreen causes blank screen

The minimal code to reproduce the issue:

function love.load()
push = require 'push'
push:setupScreen(1920, 1080, 0, 0)
end

function love.draw()
push:start()
love.graphics.rectangle('fill',10,10,100,100)
push:finish()
end

A window running at my desktop resolution opens but nothing within push:start() and push:finish() draws. If I move love.graphics.rectangle to be after push:finish it does draw.

If I change window width & height to any other value, either in push:setupScreen or by calling push:resize rectangle does draw.

Error

Hi, while I run my code I am getting this error. Can you please help me out here. Thanks.
Error

push.lua:101: attempt to call field 'getPixelScale' (a nil value)

Traceback

push.lua:101: in function 'initValues'
push.lua:48: in function 'setupScreen'
main.lua:16: in function 'load'
[C]: in function 'xpcall'
[C]: in function 'xpcall'

push.docx

love.window.setMode options are limited and reset defaults from say conf.lua

The code:

  love.window.setMode(self._RWIDTH, self._RHEIGHT, {
    fullscreen = self._fullscreen,
    resizable = self._resizable,
    highdpi = self._highdpi
  })

Is meant to enable the options in the setupScreen API.

The issue is that conf.lua (or other ways to set these options) might set a bunch of options which are thrown out for the defaults when this chunk is called.

An example is vsync. Set vsync to 0 in conf.lua, and when Push is initialized, it will reset vsync back to 1.

Removing this chunk of code and allowing conf.lua to set the values works... as push still relies on those flags for other operations.

Not sure what the best approach to this problem is. One possible solution is to query for all properties for their current values: https://love2d.org/wiki/love.window.setMode and set those in that function.

Pixellation using push with love.js

Hello!

Not sure if this is on push's part or love.js's, but it seems that using push while building a game with the main branch, 0.10.2, of love.js (https://github.com/TannerRogalsky/love.js/) produces an odd pixellated/dithering effect with any game, with the exception of some solid colors, like pure red; see below screenshots for a basic example of a Pong game with a greyish background color:

Without push:
image

With push:
image

Happen to know what's causing and what the easiest fix would be? Thanks so much!

Performance slowdown using w/ shaders (shine library)?

Hi, thanks so much for making this, it works flawlessly UNLESS I turn on shaders :(

I am using the Shine Library to apply a few post processing effects. When I enable these effects, I have intermittent issues with my framerate dropping way way down.

Sometimes it just sort of stutters, but other times everything starts slowing down. If I turn off the shader effects, everything is fine. If I turn the shader effects on, but turn off Push, everything is fine. It's only when both are enabled that I experience these slowdowns.

I'm attaching an example Love file where this behavior happens, maybe you can make some sense of this behavior, or it's a known thing with shaders? To re-create sometimes I have to quit/reload the game several times to trigger the issue, though often it manifests on first load.

FYI you can kick by hitting the space bar, sometimes it seems like actually doing something in game also triggers the slowdown.

OurTeam.love.zip

Canvas Transformations not Preserved when Drawn in Update()

When the game dimensions are a different aspect ratio than the screen dimensions, all canvases are drawn shifted relative to what they should be. It was an issue that was bugging me for a while, and pgimeno on the love2d forums helped me resolve it.

This only happens when the canvases are drawn in love.update (it works fine if the canvases are drawn in love.load).

pgimeno helped me resolve the issue by adding love.graphics.origin() before i draw the canvas. This resolves the issue, but the behaviour is still not what I'dve expect, so it might be considered a bug.

Example:

This should a 1280x720 blue rectangle over a 1280x720 game (when the screen is 1500x720):

The conf.lua

function love.conf(t)
	t.window.width = 1500
	t.window.height = 720
end

The main.lua:

push = require("push")

local gameWidth, gameHeight = 1280,720

local windowWidth, windowHeight = love.window.getMode()
push:setupScreen(gameWidth,gameHeight,windowWidth,windowHeight,{fullscreen=false})

function love.update(dt)
	thisCanvas = love.graphics.newCanvas(1280,720)
	love.graphics.setCanvas(thisCanvas)
	love.graphics.clear()

	love.graphics.setColor(0,1,1,1)
	love.graphics.rectangle('fill',0,0,1280,720)
	love.graphics.setColor(1,1,1,1)

	love.graphics.setCanvas()
end

function love.draw()
	push:start()

	love.graphics.rectangle('line',1,1,1280,720)
	love.graphics.draw(thisCanvas,0,0)

	push:finish()
end

The canvas (blue) appears shifted right relative to where it should be by 110px (which is the same as how much the game is shifted relative to the screen, but this is an extra 110px on top of that).

Using vrld's shine shaders with push

How can I apply chained vrld's shine post processing shader effects to push?. An example or syntax will be helpful! I know there is a setShader function, but cannot get any result.

error at 135

whenever I try running my project, it gives me: Error

push.lua:135: attempt to index field '_drawFunctions' (a nil value)

Traceback

push.lua:135: in function 'apply'
main.lua:39: in function 'draw'
[C]: in function 'xpcall'

please help me!

Background color

There is an issue with background color. I fixed it by commenting out line 182 in push:finish.
--love.graphics.setBackgroundColor(unpack(self._borderColor))
It was preventing me from setting a background color

Is my game going to do fine with that line out or that line is important. BTW thank you for your awesome library. C'est formidable

push:setupScreen makes the program close

push:setupScreen is making the program close. I have the following files:

main.lua

push = require 'vendor/push'

love.window.setMode(0, 0, {
  fullscreen = true,
  vsync = -1
})
WINDOW_WIDTH, WINDOW_HEIGHT = love.graphics.getDimensions()
WINDOW_WIDTH = WINDOW_WIDTH/2
WINDOW_HEIGHT = WINDOW_HEIGHT/2

VIRTUAL_WIDTH = 432
VIRTUAL_HEIGHT = 243

function love.load()
  love.graphics.setDefaultFilter('nearest', 'nearest')

  push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
    fullscreen = false,
    resizable = false,
    highdpi = true
  })
end

conf.lua

function love.conf(t)
  t.window.width = 1280
  t.window.height = 720
  t.modules.joystick = false
  t.externalstorage = true
end

When running love . in the root folder, love opens but immediatly closes. If I comment the push:setupScreen function call, the program keeps opened

I'm using Love2d 11.3 (latest version at the moment) and my GPU is an AMD Radeon HD 8610G and its drivers are up to date

Border color

If you set love.graphics.setBackgroundColor( ) then the border color becomes that color, as opposed to the default/set color with push:setBorderColor().

Add Multi-Pass Shader Support

Just dropping a note to say I'd still love to see this, support for applying shaders in multiple passes in conjunction with push.

As a reminder, we discussed this in another closed issue:

#10

Push:finish() Shader Processing After window resize or fullscreen mode

Issue: When you resize the window and apply a table of shaders to push using the push:finish(shaders) the first shader in the table is offset on screen in the incorrect position. Subsequent shaders in the table are processed in the correct position.

Created a scenario where I have a shader create a circle at a predefined pos. I made a table of copies of this one shader object and passed it to push:finish(). First is offset, subseuqent are applied in the same position. Problem goes away if you return screen to original non-resized position.

Problem does not exist if you are not in full screen mode or the window has not be resized.

Cut canvas on the 3rd(and the next) full screen switching

The init:

GLOBAL_SETTING = {
    FULL_SCREEN = false,
    WINDOW_WIDTH = 640,
    WINDOW_HEIGHT = 480
}

    push:setupScreen(GLOBAL_SETTING.WINDOW_WIDTH, GLOBAL_SETTING.WINDOW_HEIGHT,
	GLOBAL_SETTING.WINDOW_WIDTH, GLOBAL_SETTING.WINDOW_HEIGHT,
        {fullscreen = GLOBAL_SETTING.FULL_SCREEN, resizable = false})

Usage:
push:switchFullscreen()
I get cut canvas after switching modes Window -> FullScreen -> Window -> FullScreen
It looks like some values get broken.

My workaround:

	--this workaround makes PUSH lib switch full screen/window w/o problems
	--passing the constant screen resolution every time
    push:switchFullscreen(GLOBAL_SETTING.WINDOW_WIDTH,GLOBAL_SETTING.WINDOW_HEIGHT)

I use "push" in our open source game project Zabuyaki
https://github.com/thomasgoldstein/zabuyaki
It is easy to check. Use F11 to switch Windowed/FullScreen modes.
controls: X key - Ok, C key - Cancel, Arrow keys

Performance is terrible on Android if canvas flag = true

Running this code:

function love.load()
push = require 'push'
push:setupScreen(1920, 1080, 0, 0,{
fullscreen = true,
})
font50 = love.graphics.newFont(50)
end

function love.draw()
push:start()
love.graphics.print({{0,255,0,255}, 'FPS: ' .. tostring(love.timer.getFPS())}, font50)
push:finish()
end

on a Huawei P20 Lite results in an FPS of 15. Running it on a Nokia 6, 36.

For a more real world example running a game I'm making on those phones gets about 10 and 13 average FPS respectively and feels really choppy and laggy. Even my much more powerful/modern Pixel 4a can only get 54 in some situations.

When I set the canvas flag to false in push:setupScreen performance suddenly increases massively. All those phones are able to run the test code and my game at a steady 60 FPS (only dropping when loading things) and feel really smooth and responsive, like they do if I don't use push.lua. On the Windows devices I have my game gets a locked 60 FPS so I can't really tell if disabling canvas makes any difference. I think GPU usage falls a bit in task manager but it's negligible. However on Android this is a real issue, as canvas is set to true by default and most people won't realise turning it off makes a difference. I only did because I was going through all of the arguments you can supply to push:setupScreen to try and fix my game's lackluster performance.

Also after discovering the canvas flag I found this post where someone else has had the same issue https://love2d.org/forums/viewtopic.php?t=80738&start=50

Android and iOS notice

I suggest you add a HUGE note somewhere in the README and/or in the examples saying:

Android and iOS have dynamic sizes and you need to call push:resize in love.resize or push won't work at all

Error push.lua:48 : bad argument # 2 to 'windowUpdateMode'(number expected, got table)

Please help me I'm using push library in my project ..and i copied the code push.lua provided by you in push.lua file and when i run the program this error is expected on this line of code
windowUpdateMode(self._RWIDTH, self._RHEIGHT, {
fullscreen = self._fullscreen,
resizable = self._resizable,
highdpi = self._highdpi
})
`function push:setupScreen(WWIDTH, WHEIGHT, RWIDTH, RHEIGHT, settings)

settings = settings or {}

self._WWIDTH, self._WHEIGHT = WWIDTH, WHEIGHT
self._RWIDTH, self._RHEIGHT = RWIDTH, RHEIGHT

self:applySettings(self.defaults) --set defaults first
self:applySettings(settings) --then fill with custom settings

windowUpdateMode(self._RWIDTH, self._RHEIGHT, {
fullscreen = self._fullscreen,
resizable = self._resizable,
highdpi = self._highdpi
})

self:initValues()

if self._canvas then
self:setupCanvas({ "default" }) --setup canvas
end

self._borderColor = {0, 0, 0}

self._drawFunctions = {
["start"] = self.start,
["end"] = self.finish
}

return self
end`

push starts game scaled, fonts render strange, resize breaks virtual resolution

Hello!

First wanna say this library is great and has been an amazing tool to have throughout the 10.0 lifecycle :) So thank you so much for the awesome work you've done with it!

Transitioning to v11 now and noticing some issues in using push with a very simple example:

VIRTUAL_WIDTH = 384
VIRTUAL_HEIGHT = 216

WINDOW_WIDTH = 1280
WINDOW_HEIGHT = 720

gFonts = {
    ['small'] = love.graphics.newFont('fonts/font.ttf', 8)
}

function love.load()
    love.graphics.setDefaultFilter('nearest', 'nearest')
    love.graphics.setFont(gFonts['small'])

    push:setupScreen(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, WINDOW_WIDTH, WINDOW_HEIGHT, {
        fullscreen = false,
        vsync = true,
        resizable = true
    })
end

function love.resize(w, h)
    push:resize(w, h)
end

function love.keypressed(key)
    if key == 'escape' then
        love.event.quit()
    end
end

function love.update(dt)

end

function love.draw()
    push:start()
    love.graphics.print('Hello, world!')
    push:finish()
end

In running this with LÖVE 10.2, I get the following expected screenshot with push:

image

However, when running Version 11.1, I get the following:

image

Notice that the second one is much more zoomed in than it should be, the font being blurry, and when you resize the game window in 11.1, it ends up going to the window's resolution rather than the virtual resolution. Not sure if there's a LÖVE feature I'm missing with the new update or if it's an issue with push, but if you have any ideas it would be much appreciated :) Thanks so much!!

Letterbox color vs BorderColor vs Background Color

Hey Ulydev, thanks for the useful library!

One thing I noticed with https://github.com/tomlum/simpleScale library is the option to set the letterbox color.

With your library, setting the background (borderColor?) color sets the background color of the virtual screen as well as the letterbox.

This is strange because the letterbox color almost always should be black, and the background color of the actual window should be the "background color" of the game in question. While ideally a game wouldn't use the native background color vs images / sprites, sometimes it matters.

One simple fix is to add:

    backgroundR, backgroundG, backgroundB = 0.33, 0.33, 0.33
    local oc = {}
    oc.r, oc.g, oc.b, oc.a = love.graphics.getColor()
    love.graphics.setColor(backgroundR, backgroundG, backgroundB)
    love.graphics.rectangle("fill", 0, 0, self._WWIDTH, self._WHEIGHT)
    love.graphics.setColor(oc.r,oc.g,oc.b,oc.a)

Just before Push:start(), which gives us a grey background color and black letterboxes.

Does adding a configurable option to add this make sense?

white screen

Only White screen with v0.3 on Mac 10.14 Beta


Same code and same config with v0.2 return this error

Error: push.lua:101: attempt to call field 'getPixelScale' (a nil value)
stack traceback:
[string "boot.lua"]:637: in function 'getPixelScale'
push.lua:101: in function 'initValues'
push.lua:48: in function 'setupScreen'
main.lua:47: in function 'load'
[string "boot.lua"]:488: in function <[string "boot.lua"]:487>
[C]: in function 'xpcall'
[string "boot.lua"]:650: in function <[string "boot.lua"]:639>
[C]: in function 'xpcall'

support for an smaller active area than the window, screensize

An technique to prevent dark letterboxes by pixelart game sis to draw a larger background on screen, as large as the screen in any size. But todo this you have to center the active gamearea on screen, when the windowsize or the screensizes are larger.

When i try to use push, and the nativ game size is smaller than the windowsizes, the active area is located on the top-right.

Love 11.2 Issues

I ran into a few issues with love 11, and thought you would like to know.

Current version doesn't support the stencil update. This can be remedied by updating the setCanvas calls to include the new stencil key addition:

e.g. push.lua:83

return love.graphics.setCanvas { self:getCanvasTable(name).canvas, stencil = true }

I made the same addition to the remaining calls

While I haven't had any issues after this update, I am new to Love and I'm not if there are potential side-effects that they may cause.

The other issue is that getDPIScale on a retina screen is throwing the scaling off (guessing it's returning 4), setting the canvas to scale 25% of the intended size. To get around this, I had to change line 101:

self._PSCALE = self._highdpi and 1 -- love.window.getDPIScale() or 1

Anyways, loving the library (no pun intended)! 👍

Full screen pixel-perfect mode request

I'd like to have "pixel perfect" mode
where all the scaled pixels are squares: 1x1, 2x2, 3x3 and such.
Ofc, you'll have to leave some unused space (borders) at every side of the screen.

With our project I just cannot stand the pixels tearing. When scaled pixels have different width
you see bad tearing at the full screen mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.