Testing the new things in 0.9.0

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Testing the new things in 0.9.0

Post by Santos »

So I thought it would be cool to have a thread when 0.9.0 is released to talk about and show examples of the new functionality, but then I thought, why wait, it could be useful to talk about what's new now so it can be documented and tested with the nightly builds.

A more complete list of new things is here, but here's a list of some of the new functions:

Font:getAscent
Font:getDescent
Font:getBaseline
Font:get/setFilter
Font:hasGlyph

love.graphics.newGeometry
[wiki]Geometry:setVertexColors[/wiki]
[wiki]Geometry:setVertex[/wiki]
[wiki]Geometry:getVertex[/wiki]
[wiki]Geometry:hasVertexColors[/wiki]
[wiki]Geometry:getVertexCount[/wiki]
[wiki]Geometry:flip[/wiki]

love.thread.newChannel
love.thread.getChannel
[wiki]Channel:push[/wiki]
[wiki]Channel:pop[/wiki]
[wiki]Channel:demand[/wiki]
[wiki]Channel:clear[/wiki]
[wiki]Channel:supply[/wiki]
[wiki]Channel:getCount[/wiki]
[wiki]Thread:getError[/wiki]

love.graphics.setBlendMode("replace")
love.graphics.setCanvases
love.graphics.setColorMask
love.graphics.setAlphaTest
love.graphics.origin
love.graphics.getRendererInfo

love.graphics.isSupported("mipmap")
love.graphics.isSupported("dxt")
love.graphics.isSupported("bc5")
love.graphics.isSupported("hdrcanvas")
love.graphics.isSupported("multicanvas")

love.image.newCompressedData
love.image.isCompressed
CompressedData:getMipmapCount

Image:isCompressed
Image:refresh
Image:getData
Image:get/setMipmapFilter

love.math.randomseed
love.math.random
love.math.randomnormal

love.math.newRandomGenerator
[wiki]RandomGenerator:randomseed[/wiki]
[wiki]RandomGenerator:random[/wiki]
[wiki]RandomGenerator:randomnormal[/wiki]

love.math.newBezierCurve
BezierCurve:getDegree
BezierCurve:setControlPoint
BezierCurve:getControlPoint
BezierCurve:insertControlPoint
BezierCurve:eval
BezierCurve:render

love.math.triangulate
love.math.isConvex
love.math.noise

love.timer.getAverageDelta

love.window.setMode
love.window.isVisible

love.mousefocus
love.window.hasMouseFocus

love.resize
love.visible

love.joystickaxis
love.joystickhat

love.joystick.reload

Contact:getChildren

ParticleSystem:emit
ParticleSystem:setRelativeDirection
ParticleSystem:setAreaSpread


Here's an example showcasing [wiki]ParticleSystem:emit[/wiki], as well as some other changes:

Code: Select all

function love.load()
	-- love.graphics.newImage can accept FileData.
	image = love.graphics.newImage(
	love.filesystem.newFileData('iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAADmUlEQVR42o1X2XLUMBCUfO0dCCHACw/w/38FFaA4l7DZy5KQlp6tro6S4Kou2S55pueWfUrJ5avJaDO6jCGjxzvv/l1lUwQS4Gjl9xHfRnrmfZG/7fBQ1knGLGOZsciYQpAJCQQTGkhwECW8d8R6oPcnEkagKL/IuMq4zngJEi0UHYERKythz4yQdyRFRyjeZNxl7DN2RsoIzKH4bcY73BuBKATYskCeYEsT7d9B8W3G94yf0HkiYQSK219B+Xt4YkKxUqWaD5wjUb7Zg0BR/InklmtrBFZw+2usS8TfPZJAiQSlR5JzRAh+w9MtSJ28yiFYAVOpAEf3LQluSGlD5DzutYIW2FeUrzP+FM9wFQxYWbETi5IIZXK8tvJ9B+XPMi4znsPovqsoifLsJO6RrDaF5g2+Ny96kjUgvCuU/NBJHR9FsSk/IGv3iGki4Q1ZbWsPq81yQ4cQz4Cuk2ThJuOpti2L16hn85J1UO6kU7h3iXUinhoo3GcCoeLmlsppm/E14wZEDhJvW6dQXMr4DZT0lRAN2NtqDkRxr3lhhzL6kvEZHhnJegdFMyTakcjMRGZLxM4EUqXGdQbcgcQaOEoi2jzZQfkVPKUGNaacQ5AkW/UaAetqWxDgPuFBYECNb0FgxDtHvcQ8cC5DT1b7J3oBz4Mke63R7KlioiRhCwxMID0BvnopP1beUeWEyvnB9k2Arqu4UZ+9HFaszEYS6IncEsJbaVwagkE7oav0fk6wOc4MGygKJJAbzRztdkHJ5qVvTA0aAl+Zdpa1F5iWAzLdkWLugDPsvQSZRoyxPlAIzjtxt/ZwtuoaCq7J+kY8YGSndLTrK7kyQOaik0OllqKRMEsWlFxsvZI2b/Q0D0w2e2pWa8Wa9S2SqgcRTSi9mkp4nJS7JeF5Go5Uu0E2a4wjZbinA4ijg0nzQELfS3bbeED3ukUHG8lSX4F7oGTdf/aSgEQ+nwlLaf3CxHtBB4dePowkoHb+80Kcy9STt4uhP8pkNQJbjNkbZPCIYTKn7uYqjSVW3kfJATuYWNjKLPmW8aEYbAT2IGCbNiCwhDdasjrJn1CQHxUeblwNDQbYHTz9sYx3JuDoh+EWzWROApJYyT8m+pykJAdK1g2drtbcB/b40EbuBOHo5KAZhEyA8CBhcVJB5i37WzqdMT3+jrVXtzQ0HPXzIGWnx3P9OWmkJO/96BoB90jJ+cq5wFeqwFf+ltQ4JZ7+AnD/oN6MfkK1AAAAAElFTkSuQmCC', '', 'base64'))

	-- ParticleSystems have a default buffer size of 1000.
	p = love.graphics.newParticleSystem(image)

	p:setPosition(400, 300)
	p:setSpread(2*math.pi)
	p:setSpeed(100, 200)

	-- Colors as tables with optional alpha.
	pink = {255, 0, 200}
	blue = {0, 200, 255, 0}
	p:setColors(pink, blue)

	-- Name changes ahead.
	p:setEmitterLifetime(-1)
	p:setParticleLifetime(2)
end

function love.keypressed()
	-- Manually emitting particles.
	p:emit(100)
end

function love.update(dt)
	p:update(dt)
end

function love.draw()
	love.graphics.draw(p)
end
So yeah, I guess, like, if anyone is feeling inspired at any time, we could make examples, and/or create and answer questions, or if you're a dev you could engage in a soliloquy about what inspired the new things, and tales about technical and design challenges, or you know, anything! :ultrahappy:
batatinha
Prole
Posts: 22
Joined: Mon Jun 24, 2013 3:49 am

Re: Testing the new things in 0.9.0

Post by batatinha »

To be honest i didn't liked the removal of setColorMode and Quads, i guess the new way is kinda less dynamic... But IDK, i'm new to this engine, i'm probably wrong... But the fix'd issues list is great!
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Testing the new things in 0.9.0

Post by slime »

batatinha wrote:To be honest i didn't liked the removal of setColorMode and Quads, i guess the new way is kinda less dynamic... But IDK, i'm new to this engine, i'm probably wrong... But the fix'd issues list is great!
The ColorModes were mostly useless - if you want the "replace" ColorMode you can just do love.graphics.setColor(255, 255, 255). love.graphics.newQuad still exists for convenience, but it now returns a Geometry. Geometries are way more powerful and dynamic than Quads were. :P
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Testing the new things in 0.9.0

Post by raidho36 »

Will vertex shader only affect geometry, or it may apply to all render operations?
Automatik
Citizen
Posts: 57
Joined: Sun Feb 17, 2013 7:05 pm

Re: Testing the new things in 0.9.0

Post by Automatik »

If by "geometry", you mean the replacement for quad, then no. It's gonna be for everything.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: Testing the new things in 0.9.0

Post by Ref »

And don't forget love.graphics.setCaption is now love.window.setCaption.
Waiting for someone to write a simple thread example for Love 0.9 - would same me some head scratching and banging.
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Testing the new things in 0.9.0

Post by slime »

raidho36 wrote:Will vertex shader only affect geometry, or it may apply to all render operations?
Anything that is drawn with a vertex shader active will be affected by it.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Testing the new things in 0.9.0

Post by raidho36 »

Well then, how exactly text rendering will be affected by vertex shader?
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Testing the new things in 0.9.0

Post by Santos »

Oh yeah, all the window related stuff is in love.window now. :) I think this is nice API-wise, but was there anything else which prompted this change?

Speaking of window related stuff, the new things you can do with love.window.setMode are so freaking cool!

Code: Select all

function love.load()
	love.window.setMode(800, 600, {
		fullscreen = false,
		vsync = true,
		fsaa = 0,
		resizable = false,
		borderless = false,
		centered = true,
	})
end

function love.draw()
	width, height, flags = love.window.getMode()

	love.graphics.print(
		'resizable: '..tostring(flags.resizable)..'\n'..
		'borderless: '..tostring(flags.borderless)..'\n'..
		'centered: '..tostring(flags.centered),
	10, 10)
end

function love.keypressed(key)
	width, height, flags = love.window.getMode()

	if key == 'r' then
		flags.resizable = not flags.resizable
	elseif key == 'b' then
		flags.borderless = not flags.borderless
	elseif key == 'c' then
		flags.centered = not flags.centered
	end

	love.window.setMode(width, height, flags)
end
User avatar
slime
Solid Snayke
Posts: 3166
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Testing the new things in 0.9.0

Post by slime »

raidho36 wrote:Well then, how exactly text rendering will be affected by vertex shader?
However you want. Each glyph character in a string you print has 4 vertices that form a bounding box around the glyph.

A simple pass-through vertex shader (does exactly the same thing as if no vertex shader were active) would look like this:

Code: Select all

shader = love.graphics.newShader[[
vec4 position(mat4 modelviewproj_matrix, vec4 vertex)
{
    return modelviewproj_matrix * vertex;
}
]]
LÖVE sets the varying color and texture coordinate from the vertex information for you right before calling the position function you define, so you can also change that inside the position function by changing the VaryingColor and VaryingTexCoord vec4 variables.

Santos wrote:Oh yeah, all the window related stuff is in love.window now. :) I think this is nice API-wise, but was there anything else which prompted this change?
It makes sense API-wise as you said (especially with new functions like love.window.isVisible), and it also helps reduce the huge buildup of functions in the love.graphics module.

Also, everyone should keep in mind everything in 0.9.0 is subject to abrupt change - for example File objects just got a bunch of new additions last night, and there are a couple very useful/powerful/sweet things which haven't made it into the main repository yet but hopefully will soon, as long as there aren't major fundamental/API issues with them. :)
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests