Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

screen.draw.text displaying a white block instead of text #258

Open
al-kee opened this issue Jul 9, 2021 · 4 comments
Open

screen.draw.text displaying a white block instead of text #258

al-kee opened this issue Jul 9, 2021 · 4 comments
Labels
pygame Issue arises in pygame

Comments

@al-kee
Copy link

al-kee commented Jul 9, 2021

Completely new to pgzero, helping my kids with the book Coding Games in Python. On one of the first exercise that just should print out the Hello, instead of Hello we're getting a white block. I've tried changing the font, and that does not change the result. Attaching a screenshot.

I'm running this on MacOS Catalina and everything looks installed properly.
Image 2021-07-08 at 9 03 PM

@lordmauve
Copy link
Owner

I don't have a Mac to develop on, but I escalated this with Pygame maintainers on Discord and they said that it might be a Mac OS X quirk with video start-up but nobody has been able to diagnose it, and it goes away if you redraw. It might be fixed in 126f7cf where we handle the VIDEOEXPOSE event.

It would be useful if someone could test this on Mac and if this is reproducible, get closer to a root cause.

Note that your script ought to have a screen.clear() at the start of draw() - but what you wrote should also work.

@lordmauve
Copy link
Owner

This may not end up relevant but @geofft just pointed out that the screen buffer starts initialised to (0, 0, 0, 0) on Mac OS but (0, 0, 0, 255) elsewhere. It shouldn't create this effect though; the alpha blending equations would produce greys, blacks and whites as expected.

a = (0, 0, 0, 0)
b = (1, 1, 1, x)

out_rgb = b.rgb * b.a + (1 - b.a) * a.rgb = (x, x, x)
out_a = b.a + (1 - b.a) * a.a = x

It would only be white if the screen was being rendered to the display by dividing the resulting premultiplied buffer and then discarding the alpha channel - which seems like an odd thing to do; you'd either just discard the alpha channel or you'd use it for blending, either of which would avoid this effect,

@r0the
Copy link
Contributor

r0the commented Dec 24, 2021

I can reproduce the problem on macOS 12 Monterey with

  • Python 3.9.9
  • pygame 2.0.1
  • pgzero 1.2.1

with the following test program:

import pgzrun
def draw():
    print(screen.surface.get_at((0, 0)))
    screen.draw.text("H e l l o", topleft=(10, 10))
pgzrun.go()

The buffer is initialised as (0, 0, 0, 0)

However, when i upgrade to pygame 2.1.1, the program works as expected:

Bildschirmfoto 2021-12-24 um 23 19 23

and the buffer is initialised as (0, 0, 0, 255)

So, upgrading pygame seems to fix this problem.

@geofft
Copy link

geofft commented Dec 24, 2021

Wow, 2.1.1 was released earlier today... In fact, upgrading fixes my issue too.

I bet this was pygame/pygame#2859. The patch looks relevant, and the problem looks like the same one as this issue (white rectangle instead of graphics).

@lordmauve lordmauve added the pygame Issue arises in pygame label Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pygame Issue arises in pygame
Projects
None yet
Development

No branches or pull requests

4 participants