push - a resolution-handling library
Re: push - a resolution-handling library
I spoke too soon. the change I made broke my shader rendering. I am not sure how fix it, so back to the drawing board
Re: push - a resolution-handling library
I am not understanding how to give a pre-existing shader to Push. One that I create with love.graphics.newCanvas() and that does not take up the entire screen.
Or how might I create a canvas with Push that has width and height parameters?
Like so:
Or how might I create a canvas with Push that has width and height parameters?
Like so:
Code: Select all
local canvas = lg.newCanvas(350,60)
function stencilFunction()
rainbow_shader:send("scaler",scaler)
rainbow_shader:send("rot",r)
push:setShader(rainbowmask_shader) --I can't use the push:(canvasName,shader) syntax here with my normal canvas
lg.print(scoretext,lg.getWidth()/2-28,30)
push:setShader()
end
local canvasList = {name = "test",shader=rainbow_shader} --how do I add my normal canvas to this so I can use push:setupCanvas on it??
push:setupCanvas(canvasList)
gameplay:update(dt)
push:setCanvas(test) --this should be applying the 'rainbow_shader' to the below rect
lg.rectangle("fill",0,0,lg.getWidth(),lg.getHeight())
push:setCanvas()
end
gameplay:draw()
lg.stencil(stencilFunction,"replace",1)
lg.setStencilTest("greater",0)
scoretext = tostring(math.floor(currentscore))
lg.setColor(1,1,1,1)
if newHighScore then
lg.draw(canvas,score.x,score.y2) -- I need my canvas to be drawn at this position, after it passes through the stencil function
end
end
Re: push - a resolution-handling library
Hmm, I'm not sure how you can display a not-fullscreen with push, it's been a while and I honestly don't remember how it works exactly. I need to go through the code again so I can help you :-) I'll be sure to reply as soon as I have some time!
- Jack Dandy
- Prole
- Posts: 49
- Joined: Mon Sep 08, 2014 4:26 pm
Re: push - a resolution-handling library
Heya. Just wanted to know if the stencil problem's been fixed?
Re: push - a resolution-handling library
It seems like it's been fixed, although I haven't tried it myself yet: https://github.com/Ulydev/push/issues/25Jack Dandy wrote: ↑Sat Jul 06, 2019 9:02 am Heya. Just wanted to know if the stencil problem's been fixed?
Re: push - a resolution-handling library
Okay - love.mouse.getPosition works well with push (using toGame) but love.mouse.setPosition doesn't seem to work (i tried both toGame and toReal).
My Github- your contribution is highly appreciated
Re: push - a resolution-handling library
Hi, push.lua seems not to work at all. I am using Love version 11.3. I don't even have any idea what is wrong, ive tried commenting out everything and it still doesn't work. Not one bit. I followed the usage tutorial but I am trying to implement a toogle so you can swith between fullscreen and window mode by pressing lalt or ralt and return simultaneously.
Please help I don't know where else to turn. I don't know if I can post a .love since I am using PAID assets and they could get ripped.
Error
push.lua 144
main.lua
conf.lua
Please help I don't know where else to turn. I don't know if I can post a .love since I am using PAID assets and they could get ripped.
Error
Code: Select all
--------------------------------------------------------------------------------
Error
libs/push-master/push.lua:144: attempt to index field '_OFFSET' (a nil value)
Traceback
libs/push-master/push.lua:144: in function 'start'
main.lua:95: in function 'draw'
[C]: in function 'xpcall'
--------------------------------------------------------------------------------
Code: Select all
love.graphics.translate(self._OFFSET.x, self._OFFSET.y)
Code: Select all
function love.load()
--resolution
screen_h = love.graphics.getHeight()
screen_w = love.graphics.getWidth()
desktop_w , desktop_h = love.window.getDesktopDimensions()
--load libraries
push = require("libs/push-master/push") --fixed screen resolution control
bitser = require("libs/bitser-master/bitser") --saving and loading tables
anim8 = require("libs/anim8-master/anim8") --animations
sti = require("libs/sti-master/sti") --tiled map loader and renderer
map = sti("maps/room01.lua")
cameraFile = require("libs/hump-master/camera") --easy camrea setup
cam = cameraFile()
--load sprites
sprites = {}
sprites.walk_cycle = love.graphics.newImage("sprites/walk_cycle-2x.png")
--animations setup
hero = {}
hero.grid = anim8.newGrid(16, 24, 256, 216)
hero.front_walk = anim8.newAnimation(hero.grid('9-12', 1), 0.5)
--hero start position
for k, object in pairs(map.objects) do
if object.name == "Player" then
player = object
break
end
end
--custom layers
layer = map:addCustomLayer("Sprites",3)
--create player object
layer.player = {
x = player.x,
y = player.y,
ox = (16/2) - (16/2),
oy = (24/2) - (8/2)
}
--Add controls to the player
layer.update = function(self, dt)
local speed = 96 * dt
--movement
if love.keyboard.isDown("w","up") then
self.player.y = self.player.y - speed
end
if love.keyboard.isDown("a","left") then
self.player.x = self.player.x - speed
end
if love.keyboard.isDown("s","down") then
self.player.y = self.player.y + speed
end
if love.keyboard.isDown("d","right") then
self.player.x = self.player.x + speed
end
end
--draw player
layer.draw = function(self)
hero.front_walk:draw(
sprites.walk_cycle,
math.floor(self.player.x),
math.floor(self.player.y),
0,
1,
1,
self.player.ox,
self.player.oy
)
end
--remove unneeded object layers
map:removeLayer("POS")
end
function love.update(dt)
map:update(dt)
cam:lookAt(player.x , player.y)
hero.front_walk:update(dt)
end
function love.keypressed(key, scancode, isrepeat)
--quit game
if key == "escape" then
love.event.quit()
end
--reatart game
if key == "backspace" then
love.event.quit("restart")
end
--toogle fullscreen
if ((key == "lalt") or (key == "ralt")) and key == "return" then
push:setupScreen(screen_w, screen_h, desktop_w, desktop_h, {fullscreen = true})
end
end
function love.draw()
push:start()
--backgrounds and parallax
love.graphics.setColor(0.3, 0.3, 1)
love.graphics.rectangle("fill", 0, 0, screen_w, screen_h)
love.graphics.setColor(1, 1, 1)
--render world
cam:attach()
--you must scale and translate or camera wont budge
love.graphics.scale(2,2)
local p = map.layers["Sprites"].player
local tx = math.ceil(p.x - screen_w/18.8) --(6.1 2x scale) (16.2 fullscreen)
local ty = math.ceil(p.y - screen_h/48) --(16 2x scale) (32 fullscreen)
love.graphics.translate(-tx, -ty)
--map needs to be drawn layer by layer in reverse order
map:drawLayer(map.layers["Under L2"])
map:drawLayer(map.layers["Under L1"])
map:drawLayer(map.layers["Sprites"])
map:drawLayer(map.layers["Over L1"])
map:drawLayer(map.layers["Over L2"])
cam:detach()
--overhead UI
love.graphics.setColor(1,0,0)
love.graphics.line(screen_w/2,0,screen_w/2,screen_h)
love.graphics.line(0,screen_h/2,screen_w,screen_h/2)
love.graphics.setColor(1,1,1)
push:finish()
end
Code: Select all
function love.conf(t)
t.window.width = 64*16
t.window.height = 64*9
--t.window.borderless = true
t.window.fullscreen = false
t.window.title = "RPG_project 01"
end
"kuzika" literally means "to burry"
Re: push - a resolution-handling library
You're not calling push:setupScreen for normal (non-full-screen use), but you're using push regardless of whether you're in window or full-screen mode. The error likely comes from not calling setupScreen in that code path.
There are two possible ways to fix it. 1) Have a variable 'fullScreen' that is true when you enter full-screen mode, and only call push:start() and push:finish() if you're in fullscreen; and 2) Initialize Push with the same dimensions as the window. The first method has the advantage that you don't have the additional overhead of Push when it's not needed; the second method has the advantage of its simplicity, and the possibility of using a different screen resolution in future.
By the way, your method to set full-screen can't work:
Code: Select all
if ((key == "lalt") or (key == "ralt")) and key == "return" then
Code: Select all
if (love.keyboard.isDown("lalt") or love.keyboard.isDown("ralt")) and key == "return" then
Re: push - a resolution-handling library
Thanks, I was trying to call the push setup inside a keypress and forgot it needs to be initialized beforehand like you explained. I think I prefer the second option. However this doesn't really work well with my camera setup, that's my fault though. I need to read up on some more documentation about love.graphics.translate(). Anyway thanks again and nice and simple lib keep it up.
"kuzika" literally means "to burry"
Re: push - a resolution-handling library
You're not supposed to use love.graphics.translate/scale with a camera; the camera should handle that for you. But this starts to go off topic; feel free to open a new thread in the Support and Development forum. I'm not comfortable with hijacking Ulydev's thread for support of unrelated topics.
Who is online
Users browsing this forum: No registered users and 2 guests