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

Re: Testing the new things in 0.9.0

Post by Santos »

Here's an example using some new Font methods:
font_methods.png
font_methods.png (62.46 KiB) Viewed 2593 times

Code: Select all

function love.load()
	Font = love.graphics.setNewFont(50)

	colors = {
		height = {230, 159, 0},
		ascent = {0, 158, 115},
		descent = {213, 94, 0},
		baseline = {86, 180, 223},
	}
end

function love.draw()
	love.graphics.setColor(colors.height)
	love.graphics.rectangle('fill', 200*0, 0, 200, Font:getHeight())
	love.graphics.setColor(colors.ascent)
	love.graphics.rectangle('fill', 200*1, Font:getBaseline()-Font:getAscent(), 200, Font:getAscent())
	love.graphics.setColor(colors.descent)
	love.graphics.rectangle('fill', 200*2, Font:getBaseline(), 200, -Font:getDescent())
	love.graphics.setColor(colors.baseline)
	love.graphics.rectangle('fill', 200*3, 0, 200, Font:getBaseline())

	love.graphics.setColor(255, 255, 255)
	love.graphics.printf('abcdefghijklmnopqrstuvwxyz', 0, 0, 800, 'center')

	love.graphics.setColor(colors.height)
	love.graphics.print('\n\nFont:getHeight() : '..Font:getHeight(), 0, 0)
	love.graphics.setColor(colors.ascent)
	love.graphics.print('\n\n\nFont:getAscent() : '..Font:getAscent(), 0, 0)
	love.graphics.setColor(colors.descent)
	love.graphics.print('\n\n\n\nFont:getDescent() : '..Font:getDescent(), 0, 0)
	love.graphics.setColor(colors.baseline)
	love.graphics.print('\n\n\n\n\nFont:getBaseline() : '..Font:getBaseline(), 0, 0)
	love.graphics.setColor(200, 200, 200)
	love.graphics.print('\n\n\n\n\n\nFont:hasGlyph("Ö") : '..tostring(Font:hasGlyph('Ö')), 0, 0)
	love.graphics.print('\n\n\n\n\n\n\nFont:hasGlyph("の") : '..tostring(Font:hasGlyph('の')), 0, 0)
end
From Wikipedia:

Image

This displays some renderer info:

Code: Select all

function love.draw()
	love.graphics.print("love.graphics.getRendererInfo('name'): "..love.graphics.getRendererInfo('name'), 20, 20)
	love.graphics.print("love.graphics.getRendererInfo('version'): "..love.graphics.getRendererInfo('version'), 20, 40)
	love.graphics.print("love.graphics.getRendererInfo('vendor'): "..love.graphics.getRendererInfo('vendor'), 20, 60)
	love.graphics.print("love.graphics.getRendererInfo('device'): "..love.graphics.getRendererInfo('device'), 20, 80)
end
I'm wondering, what could this information be used for?
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 »

Each glyph character in a string you print has 4 vertices that form a bounding box around the glyph.
So text is rendered per glyph as dual-tri quadrilateral. That answers my question, thanks.
User avatar
slime
Solid Snayke
Posts: 3163
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 »

Santos wrote:This displays some renderer info:

Code: Select all

function love.draw()
	love.graphics.print("love.graphics.getRendererInfo('name'): "..love.graphics.getRendererInfo('name'), 20, 20)
	love.graphics.print("love.graphics.getRendererInfo('version'): "..love.graphics.getRendererInfo('version'), 20, 40)
	love.graphics.print("love.graphics.getRendererInfo('vendor'): "..love.graphics.getRendererInfo('vendor'), 20, 60)
	love.graphics.print("love.graphics.getRendererInfo('device'): "..love.graphics.getRendererInfo('device'), 20, 80)
end
I'm wondering, what could this information be used for?
It's mostly for debugging, it can really help solve graphics issues if a game outputs that info to a log or error screen so users having the issues can show the output to the game's creator. For example maybe a game fails to load on some systems, or loads fine but seems to be broken sometimes, and it turns out it only happens on ATI cards of a certain generation with an old driver in Windows (true story.)

There's also a possibility of some of the functions being used to display nicer "your computer sucks, upgrade it" messages to users. :P
User avatar
Lafolie
Inner party member
Posts: 809
Joined: Tue Apr 05, 2011 2:59 pm
Location: SR388
Contact:

Re: Testing the new things in 0.9.0

Post by Lafolie »

Is there a function to retrieve the X-Height of a typeface? Having studied typography I've been eagerly awaiting these features.

Edit: Following a short discussion on IRC (which someone took place, despite the intolerable amount of crap being spewed about the place), I found that the following meta is available in 0.9.0, I'll leave the diagram here for reference.

Image
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.
User avatar
slime
Solid Snayke
Posts: 3163
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 »

You'll only be able to get some of that via GlyphData (most of the internal GlyphData and Rasterizer object methods have been exposed to Lua in 0.9.0.)
spectralcanine
Citizen
Posts: 65
Joined: Sat Dec 22, 2012 8:17 am

Re: Testing the new things in 0.9.0

Post by spectralcanine »

Sorry for the lack of research on my part, but can we upload any uniforms and attributes, and use any varyings we want in shaders? Or is it the same SFML deal where you only support the old GLSL 100 predefined variables?
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Testing the new things in 0.9.0

Post by Jasoco »

Santos wrote:Here's an example using some new Font methods:
font_methods.png
So are Ascent and Baseline always going to be the same value? Is there a situation where they'd be different?
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 »

I was wondering that too, and indeed they can be different depending on the font, here's a test with Crafty Girls:
Crafty Girls.png
Crafty Girls.png (108.67 KiB) Viewed 2516 times

Here's an example which plays a tone when the window is visible, and stops it when it's not.

Code: Select all

function love.load()
	tonesounddata = love.sound.newSoundData(44100,44100,16,1)
	for i=0, 44100 do tonesounddata:setSample(i, math.sin(440*(2*math.pi/44100)*i)*0.2)	end
	tone = love.audio.newSource(tonesounddata)
	tone:setLooping(true)

	pingsounddata = love.sound.newSoundData(44100,44100,16,1)
	for i=0, 44100 do pingsounddata:setSample(i, math.sin(440*2*(2*math.pi/44100)*i)*0.3*(-(i - 44100) / 44100)) end
	ping = love.audio.newSource(pingsounddata)

	tone:play()
	ping:play()
end

function love.visible(visible)
	ping:stop()
	ping:play()
end

function love.update()
	-- Source:isPlaying is new.
	if love.window.isVisible() and not tone:isPlaying() then
		tone:play()
	elseif not love.window.isVisible() and tone:isPlaying() then
		tone:stop()
	end
end
visible.love
(449 Bytes) Downloaded 104 times
The "ping" which plays when it first starts is also supposed to play when the window gains and loses visibility, but this doesn't happen, any ideas?
User avatar
slime
Solid Snayke
Posts: 3163
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 »

Santos wrote:The "ping" which plays when it first starts is also supposed to play when the window gains and loses visibility, but this doesn't happen, any ideas?
It works for me. Does the entire love.visible callback not trigger, or does the sound just not play properly? What OS?
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 »

It seems like the callback doesn't trigger, on Windows XP.

I tested something simpler too:

Code: Select all

function love.load()
	love.filesystem.write('This gets created', '')
end

function love.visible()
	love.filesystem.write('But this does not', '')
end
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot] and 5 guests