Playdate->graphics->display(); does not work in simulator

consider following program / update loop

during the update loop it first draws black and calls pd->graphics->display(); to force update whats in the screen buffer to the screen then "waits" a second and then draws white in the same way.

So you are supposed to see a box appearing in black and disappearing constantly

this is just an extreme example to show the bug in the simulator. Also best to run de simulator from within the debugger as this functionality (probably the delay stuff) makes simulator hard to control / react on your commands (so you can kill it in de debugger).

static volatile char dummy;

void pdDelay(unsigned int milliseconds)
{
	unsigned int start = pd->system->getCurrentTimeMilliseconds();
	while (start + milliseconds > pd->system->getCurrentTimeMilliseconds())
	{
		(void)dummy;
	}
}
// main update function
int update(void* ud)
{
	pd->graphics->clear(kColorWhite);
	pd->graphics->fillRect(20, 20, 360, 200,kColorBlack);
	pd->graphics->display();
	pdDelay(1000);
	pd->graphics->fillRect(20, 20, 360, 200, kColorWhite);
	pd->graphics->display();
	pdDelay(1000);
	return 1;
}

on the playdate itself it works as expected (recorded using mirror)

Mirror_LITqMIWwGs

Yet in the simulator the screen remains white constantly which means that pd->graphics->display(); did not update the screen with whats in the screenbuffer and this is a bug then (in the simulator)

Thanks for catching this! I've got it filed and we'll get a fix in as soon as we can. The problem is just that the display() function wasn't implemented on the Windows/Linux simulator, so once we add that it should work as expected.

1 Like

Got this added for SDK 2.4, thanks for noticing it.

1 Like

cool thanks guys, at least it was working correctly on the device :slight_smile: