User avatar
Gavinmc42
Posts: 7997
Joined: Wed Aug 28, 2013 3:31 am

Re: Is it possible to run Pygame without startx?

Sun Oct 01, 2023 8:06 am

The next OS bookworm should be available to all the end of this month (it has to, the Pi5 uses it).
I can check things if you want.
Will be interesting to see if can work without X11 in Bookworm.
Hmm, Python doing Vulkan graphics?

I followed these steps on my Pi400 to try Bookworm now.
https://raspberrytips.com/install-debia ... pberry-pi/

Got distracted when I saw the new 14.x release of PiCore.
VKcube is fast even on a Pi4.
Would be great to do graphics on that without the bloat.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Sun Oct 01, 2023 3:25 pm

Gavinmc42 wrote:
Sun Oct 01, 2023 8:06 am
The next OS bookworm should be available to all the end of this month (it has to, the Pi5 uses it).
I can check things if you want.
Will be interesting to see if can work without X11 in Bookworm.
It will be interesting to see what Bookworm offers and on which Pi.

I haven't paid much attention to all this graphics stuff over the years because it has always just worked for me, or I have chosen options which will, and I'm not that knowledgeable about the field anyway; KMS, FKMS, DRM, SDL, Mesa, OpenGL, OpenGL ES, OpenCL, Vulcan, X11, Wayland, mean nothing to me.

Things look set to get more complicated with the Pi 5 and Bookworm release. AIUI X11 disappears for Pi 4B and Pi 5 but not for earlier so it looks like we may need to have different solutions depending on Pi, not just for PyGame, but for remote graphical access.

I guess we will find out before the month is done.

User avatar
bensimmo
Posts: 6597
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Is it possible to run Pygame without startx?

Sun Oct 01, 2023 3:35 pm

Wayland (Wayfire) is the aim for PiOS.

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Sun Oct 01, 2023 3:58 pm

bensimmo wrote:
Sun Oct 01, 2023 3:35 pm
Wayland (Wayfire) is the aim for PiOS.
Eben's comment on the Blog announcement that Bookworm "incorporates numerous enhancements, notably the transition from X11 to the Wayfire Wayland compositor on Raspberry Pi 4 and 5" suggested to me only when Pi 4 and 5.

User avatar
bensimmo
Posts: 6597
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Is it possible to run Pygame without startx?

Sun Oct 01, 2023 4:00 pm

At the moment as the older Pi cannot cope, so it is falling back to X.
I believe the aim (don't hold me to this) is to get Wayfire working on all if possible. Something to do with GPU compositing for newer Pi (4+) and having to use software on older.(3-)

Hopefully it'll all become clearer at release time.
Not my are of understanding.

User avatar
Gavinmc42
Posts: 7997
Joined: Wed Aug 28, 2013 3:31 am

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 10:37 am

I believe the aim (don't hold me to this) is to get Wayfire working on all if possible. Something to do with GPU compositing for newer Pi (4+) and having to use software on older.(3-)
New Bookworm is reported to use Wayland/Wayfire on Pi4/5 and X11/Mutter on older Pi's.

I did try Rpi Debian 12 lite but then I installed LXDE X11 desktop.
It was ok but if Wayland/Wayfire is faster on Pi4 then I might want to try that on all my Pi4's.

Found some Wayfire install scripts, hmm "sudo apt install wayfire" should work too?
Or I could just wait a few weeks for the official release ;)

Then how to use Pygame without X11?
Pywayland?
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 12:00 pm

Gavinmc42 wrote:
Mon Oct 02, 2023 10:37 am
New Bookworm is reported to use Wayland/Wayfire on Pi4/5 and X11/Mutter on older Pi's.
And on Pi 4B 1GB, and Pi 5 1GB when that arrives :?:

As said; it looks set to get more complicated with the Pi 5 and Bookworm release, not just for PyGame, but for remote graphical access.

It is perhaps not so bad configuring individual Pi's, and may perhaps require no configuration at all, but it's going to be a real PITA if one needs to use different desktop tools on a PC to access a variety of Pi on a LAN, has to remember which tool is needed to access a particular Pi.

Given one can't get a free PDF copy of MagPi 134 or HackSpace 71 until 19th of October I am guessing that's when Bookworm will be released.

User avatar
thagrol
Posts: 10342
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 12:21 pm

Gavinmc42 wrote:
Mon Oct 02, 2023 10:37 am
Then how to use Pygame without X11?
Pywayland?
Nah. Just disable wayland and switch back to X11.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
Gavinmc42
Posts: 7997
Joined: Wed Aug 28, 2013 3:31 am

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 12:53 pm

Given one can't get a free PDF copy of MagPi 134 or HackSpace 71 until 19th of October I am guessing that's when Bookworm will be released.
Yep, but is that 19th Oct Oz time or 20th :lol:

Seems there could be some VNC issues, RealVNC might be ok.

New PiCore 14 with 6.x kernel is now out, I prefer that for 24/7 Linux but I never had a good GUI for it.
I tended toward webserver remote interfaces, HTML, CSS and some JS.
Not sure yet if Vulkan needs x11/Wayland, Imgui works with Vulkan.
Nah. Just disable wayland and switch back to X11.
Yep, Pi4 or 5 are probably fast enough for any Pygame app, just not fast booting.
I actually started my Pi GUI adventures with Pygame over a decade ago.
It is just that keeping a X11 Linux OS reliable is hard, especially in loaddump apps like automotive.
I ended up with Ultibo baremetal and OpenVG, but that won't work for Pi4 and Pi5, so the search is back on for a GUI method.

Re OP's requirements - Ultibo has still proven fastest booting and OpenVG for dial needle etc but only on the old VC4 Pi's.
A Pi5 does boot fast but 20secs is not even close to the Ultibo 2-3 secs.

VulkanSceneGraph will get compiled on the Pi5 when one shows up here ;)
Will have to try some of the other suggestions on here, when a Pi5 magically appears.
Got to be a lite way to do GUIs for Pi4/5.
i refuse to learn QT, getting too old ;)
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 1:31 pm

thagrol wrote:
Mon Oct 02, 2023 12:21 pm
Gavinmc42 wrote:
Mon Oct 02, 2023 10:37 am
Then how to use Pygame without X11?
Pywayland?
Nah. Just disable wayland and switch back to X11.
If that's documented, officially or third-party, fairly easy to do, then that's what I will probably do.

But we still have the OP's PyGame problem; running PyGame on a 64-bit Bullseye not working. That's even before Pi 5 and Bookworm are thrown into the mix.
Gavinmc42 wrote:
Mon Oct 02, 2023 12:53 pm
Re OP's requirements - Ultibo has still proven fastest booting and OpenVG for dial needle etc but only on the old VC4 Pi's.
The OP's requirement is to run existing PyGame code and that's not unreasonable. Ultibo is an alternative but not a solution.
Last edited by hippy on Mon Oct 02, 2023 1:37 pm, edited 1 time in total.

User avatar
thagrol
Posts: 10342
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 1:36 pm

hippy wrote:
Mon Oct 02, 2023 1:31 pm
thagrol wrote:
Mon Oct 02, 2023 12:21 pm
Gavinmc42 wrote:
Mon Oct 02, 2023 10:37 am
Then how to use Pygame without X11?
Pywayland?
Nah. Just disable wayland and switch back to X11.
If that's documented, officially or third-party, fairly easy to do, then that's what I will probably do.
IIRC, last time I looked at the RPiOS bookworm beta it was an option in raspi-config. Haven't checked on the latest beta release though.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

User avatar
bensimmo
Posts: 6597
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 2:27 pm

hippy wrote:
Mon Oct 02, 2023 12:00 pm
...
Given one can't get a free PDF copy of MagPi 134 or HackSpace 71 until 19th of October I am guessing that's when Bookworm will be released.
They've had a three week wait window for a short while now to get the free pdf's for MagPi and HackSpace. You can pay to get the pdf earlier if you want.

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Mon Oct 02, 2023 3:04 pm

bensimmo wrote:
Mon Oct 02, 2023 2:27 pm
You can pay to get the pdf earlier if you want.
I'll perhaps drop into a newsagent and read it there if they have a copy.

valtsu23
Posts: 16
Joined: Mon Feb 14, 2022 4:46 pm

Re: Is it possible to run Pygame without startx?

Tue Oct 03, 2023 10:16 am

Thanks everyone for replying. Interesting stuff.

It seems like for me there is no benefit running 64bit OS.
Now when I have tested more 32bit OS lite with KMSDRM I found an issue.
When I call Pygame to update the screen with pygame.display.flip() or pygame.display.update(), sometimes the screen doesn't update.
This only happens with KMSDRM and not with X11.

Here is a simple test code I used. It's just a counter to 20 with 1s sleep between counts.
With KMSDRM some numbers will be skipped. I'm not sure how to tackle this. Is it an SDL2 issue or KMSDRM issue?

Code: Select all

import pygame
import time

# PyGame
size = width, height = (800, 480)
pygame.init()
screen = pygame.display.set_mode(size) # , pygame.FULLSCREEN)
pygame.mouse.set_visible(False)
screen.fill((60, 60, 60))

CENTER_X, CENTER_Y = (width / 2, height / 2)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
font_60 = pygame.font.SysFont("dejavusans", 60)
counter1 = 0
loop = True

while loop:
    counter1 += 1
    pygame.draw.rect(screen, BLACK, [CENTER_X - 150, 180, 300, 150], border_radius=10)
    counter2 = font_60.render(str(counter1),True, WHITE, BLACK)
    screen.blit(counter2, (CENTER_X - 20, CENTER_Y - 20))
    pygame.display.flip()
    time.sleep(1)
    if counter1 == 20:
        pygame.quit()
        loop = False
Tested with latest Bullseye 32bit lite and pygame 2.5.2 (SDL 2.0.14 Python 3.9.2)
Last edited by valtsu23 on Tue Oct 03, 2023 5:25 pm, edited 1 time in total.

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Tue Oct 03, 2023 3:07 pm

valtsu23 wrote:
Tue Oct 03, 2023 10:16 am
With KMSDRM some numbers will be skipped. I'm not sure how to tackle this. Is it an SDL2 issue or KMSRDM issue?
Given things seem to work okay with everything but KMSDRM (*) I would suggest that is where the problem is most likely to lie. But that wouldn't be proven unless the whole evidence chain is followed from invocation through to where something does something it shouldn't or doesn't do what it should.

I am not sure what you can or could do to tackle the issue unless you were able to follow and understand that evidence chain. I would suggest it needs knowledge and experience which most people will not have, would have to acquire to identify or resolve things themselves.

Thus I would suggest, rather than trying to identify the issue, making appropriate parties aware of the issue, hoping someone from that cohort is able and willing to tackle the issue, and focusing on workarounds and mitigations until the issue is resolved is perhaps the best you can do.

For example, multiple display updates rather than just one may be an effective workaround.

* I'm assuming "KMSRDM" was just a typo in the post and not a typo causing things to not work with the test code.

valtsu23
Posts: 16
Joined: Mon Feb 14, 2022 4:46 pm

Re: Is it possible to run Pygame without startx?

Tue Oct 03, 2023 5:41 pm

hippy wrote:
Tue Oct 03, 2023 3:07 pm
valtsu23 wrote:
Tue Oct 03, 2023 10:16 am
With KMSDRM some numbers will be skipped. I'm not sure how to tackle this. Is it an SDL2 issue or KMSRDM issue?
Given things seem to work okay with everything but KMSDRM (*) I would suggest that is where the problem is most likely to lie. But that wouldn't be proven unless the whole evidence chain is followed from invocation through to where something does something it shouldn't or doesn't do what it should.

I am not sure what you can or could do to tackle the issue unless you were able to follow and understand that evidence chain. I would suggest it needs knowledge and experience which most people will not have, would have to acquire to identify or resolve things themselves.

Thus I would suggest, rather than trying to identify the issue, making appropriate parties aware of the issue, hoping someone from that cohort is able and willing to tackle the issue, and focusing on workarounds and mitigations until the issue is resolved is perhaps the best you can do.

For example, multiple display updates rather than just one may be an effective workaround.

* I'm assuming "KMSRDM" was just a typo in the post and not a typo causing things to not work with the test code.
Yes "KMSRDM" was typo and now it's fixed.
I compiled latest SDL2 from source (2.29.0) and the problem is gone!
So the bug was in earlier SDL 2.0.14 version from apt.

hippy
Posts: 15122
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Is it possible to run Pygame without startx?

Tue Oct 03, 2023 6:10 pm

valtsu23 wrote:
Tue Oct 03, 2023 5:41 pm
I compiled latest SDL2 from source (2.29.0) and the problem is gone!
So the bug was in earlier SDL 2.0.14 version from apt.
Excellent news. We might have to return to 'how did you do that?' once Bookworm arrives but we can wait and see.

User avatar
Gavinmc42
Posts: 7997
Joined: Wed Aug 28, 2013 3:31 am

Re: Is it possible to run Pygame without startx?

Wed Oct 04, 2023 8:08 am

Excellent news. We might have to return to 'how did you do that?' once Bookworm arrives but we can wait and see.
Heard SDL2 in Bookworm is pretty good.
Re: SDL2 without X11
Report this post
Tue Aug 31, 2021 3:22 am

All you guys need for this is building SDL2 with the KMSDRM video backend.
It has been working for years.
Don't use FKMS, just full KMS. Nothing related to the old dispmanx is involved on this.
Might have to read up on SDL2, try it with PySDL2, Pygame_SDL2.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

Return to “Graphics programming”