Questions about Löve's source code structure

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Questions about Löve's source code structure

Post by T-Bone »

I'm debugging audio issues on LöveFTW. On ARM builds, the sound from playing .ogg files is just white noise. .wav files sound like they do on desktop Löve, so I initially assumed that the problem can't be in OpenAL (as that would have broken playing .wav files as well) but after trying everything I can think of with libogg/libvorbis/libvorbisfile, I'm starting to question my assumption. Do both .wav and .ogg files play through OpenAL in Löve? Any other ideas on how I can debug this is of course appreciated if you can think of anything :neko:
szensk
Party member
Posts: 155
Joined: Sat Jan 19, 2013 3:57 am

Re: Questions about Löve's source code structure

Post by szensk »

Given that .wav works, I'd suspect the VorbisDecoder. Have you tried logging a few samples from the SoundData? Compare some random sample on ARM to the same sample on x86. If the underlying samples are different, then it's probably the decoder. If they are the same, there is some other problem.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Questions about Löve's source code structure

Post by T-Bone »

szensk wrote:Given that .wav works, I'd suspect the VorbisDecoder. Have you tried logging a few samples from the SoundData? Compare some random sample on ARM to the same sample on x86. If the underlying samples are different, then it's probably the decoder. If they are the same, there is some other problem.
Thanks for this genious idea. Yes, it seems like it's the decoder because the binary samples don't match on ARM vs x86.

EDIT: LOLOLOLOLOLOLOLOLOL I had the wrong endian for ARM x'D I apologize for my stupidity.

Okay, so the final issue I have is landscape support. ANGLE doesn't support it for some reason, and I've tried the workaround mentioned there. It does work, but like they say it does affect performance quite noticably. I'm therefore looking for another solution.

What I've tried is to modify src/modules/graphics/opengl/Graphics.cpp's setViewportSize function, replacing

Code: Select all

gl.matrices.projection.back() = Matrix::ortho(0.0, width, height, 0.0);
with

Code: Select all

#ifdef LOVE_LEGENDARY_ROTATION_HACK
	Matrix proj = Matrix::ortho(0.0, height, width, 0.0);
	proj.rotate(LOVE_M_PI_2);
	proj.translate(0, -height);
	gl.matrices.projection.back() = proj;
#else
	gl.matrices.projection.back() = Matrix::ortho(0.0, width, height, 0.0);
#endif
...which does work! Everything is correctly placed on screen, and touch input works fine too... Except that everything looks ugly. It looks like it's rendering in "portrait resolution" (768x1280 in the case of my 920) and then rescaling it to landscape (1280x768), instead of rendering in the right resolution directly. I'm not sure how to solve this, I've tried switching height/width in different places but I can't figure out how to get it just right. Any ideas?

The function as a whole (untouched) looks like this (I won't blame you for not wanting to look it up):

Code: Select all

void Graphics::setViewportSize(int width, int height)
{
	this->width = width;
	this->height = height;

	if (!isCreated())
		return;

	// We want to affect the main screen, not any Canvas that's currently active
	// (not that any *should* be active when this is called.)
	std::vector<StrongRef<Canvas>> canvases = states.back().canvases;
	setCanvas();

	// Set the viewport to top-left corner.
	gl.setViewport(OpenGL::Viewport(0, 0, width, height));

	// If a canvas was bound before this function was called, it needs to be
	// made aware of the new system viewport size.
	Canvas::systemViewport = gl.getViewport();

	// Set up the projection matrix
	gl.matrices.projection.back() = Matrix::ortho(0.0, width, height, 0.0);
	// Restore the previously active Canvas.
	setCanvas(canvases);
}

What's good is that it keeps 60 FPS when I mess around with this, so if I can make it work then it'll be worth it over ANGLE's solution.

Compare these two images: https://love2d.org/imgmirrur/M6PC8.html (the background scrolls, so don't look at that, look at the text and details)

I've also attempted to modify matrices.transform instead of matrices.projection, but I'm not sure where it's set; I've tried modifying it in OpenGL::initMatrices() but it doesn't change anything, so I assume it's overwritten somewhere I can't find?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 180 guests