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

How to render pygame Surface? #40

Open
mkraljt opened this issue May 4, 2020 · 7 comments
Open

How to render pygame Surface? #40

mkraljt opened this issue May 4, 2020 · 7 comments

Comments

@mkraljt
Copy link

mkraljt commented May 4, 2020

pygamezero examples use pygame Surface to render and test/set pixels, eg Tron example.

How do you render a pygame Surface in Wasabi2D?
Or is there an alternative for Surface use-cases in pygamezero examples?

@lordmauve
Copy link
Owner

There isn't. In OpenGL there are framebuffer objects, but I think that exposing those for general use might be a long way off.

How I wrote Tron in Pygame Zero isn't exactly how I would write it with hardware accelerated graphics. I'd just keep creating line segments and trust that it will remain fast.

@einarf
Copy link

einarf commented May 4, 2020

Could in theory open up for people to write to pygame surfaces and upload to texture:
https://github.com/moderngl/moderngl-window/blob/master/examples/advanced/pygame2.py

That could be an awesome or a terrible a idea depending on how you see it.

@mkraljt
Copy link
Author

mkraljt commented May 5, 2020

Yes for the Tron game, it worked well with line segments.

And looks like you are adding tile-maps for 1.4, which was the other use I was anticipating for pygame surface

@mkraljt mkraljt closed this as completed May 5, 2020
@lordmauve
Copy link
Owner

Yes, I think this is a good idea. This would allow people to migrate from Pygame and immediately get the benefit of things like post-processing effects.

@lordmauve lordmauve reopened this May 14, 2020
@lordmauve
Copy link
Owner

Via @einarf

https://github.com/moderngl/moderngl-window/blob/master/examples/advanced/pygame2.py

Works with alpha just using pygame.Surface(self.pg_res, flags=pygame.SRCALPHA)
I get 4 bytes * width * height in pg_screen.get_view('1')

@lordmauve
Copy link
Owner

And looks like you are adding tile-maps for 1.4, which was the other use I was anticipating for pygame surface

@mkraljt Tile maps are now available on master if you'd like to try them: https://wasabi2d.readthedocs.io/en/latest/tile_maps.html

@lordmauve
Copy link
Owner

@robertpfeiffer's original article explains it better than the code linked above:
https://blubberquark.tumblr.com/post/185013752945/using-moderngl-for-post-processing-shaders-with

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants