I'm trying to implement a simple mip-mapping support for my engine. Though I rely heavily on graphic.push() and graphics.pop() function to do my camera and object drawing it is hard for me to determine which is the current scale. I was searching the wiki but didn't find any function about how to read the currently used coordinate system.
Any ideas?
Reading current transformation stack
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Reading current transformation stack
It can't be that hard to manually track it could it? You could even wrap it in a function that does this for you, enabling you to actually write a love.graphics.getScale. I'm not sure why it doesn't exist, but maybe you could ask on the http://bitbucket.org/rude/love/issues page.
Do you recognise when the world won't stop for you? Or when the days don't care what you've got to do? When the weight's too tough to lift up, what do you? Don't let them choose for you, that's on you.
Re: Reading current transformation stack
Thanks for the answer.
Well I added the missing functionality,maybe someone will find it useful:
Well I added the missing functionality,maybe someone will find it useful:
Code: Select all
local _scaleX, _scaleY, _dx, _dy, _angle = 1,1,0,0,0
local stack = {}
local old_scale = love.graphics.scale
local old_translate = love.graphics.translate
local old_rotate = love.graphics.rotate
local old_push = love.graphics.push
local old_pop = love.graphics.pop
function love.graphics.push()
local v = {_scaleX=_scaleX, _scaleY=_scaleY, _dx=_dx, _dy=_dy, _angle=_angle}
table.insert(stack, 1, v)
old_push()
end
function love.graphics.pop()
local v = stack[1]
_scaleX, _scaleY, _dx, _dy, _angle = v._scaleX, v._scaleY, v._dx, v._dy, v._angle
table.remove(stack, 1)
old_pop()
end
function love.graphics.getScale()
return _scaleX, _scaleY
end
function love.graphics.getTranslation()
return _dx,_dy
end
function love.graphics.getRotation()
return _angle
end
function love.graphics.scale(scaleX, scaleY)
scaleY = scaleY or scaleX
_scaleX, _scaleY = _scaleX+scaleX, _scaleY+scaleY
old_scale(scaleX, scaleY)
end
function love.graphics.rotate(angle)
_angle = _angle+angle
old_rotate(angle)
end
function love.graphics.translate(dx,dy)
_dx, _dy = _dx+dx, _dy+dy
old_translate(dx,dy)
end
Who is online
Users browsing this forum: Ahrefs [Bot] and 85 guests