-
-
Notifications
You must be signed in to change notification settings - Fork 168
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
Replace get_surface
method of Window
with surface
property
#2632
base: main
Are you sure you want to change the base?
Conversation
9b68e96
to
c1a66d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. Under the old system there was one display surface to rule them all, but now with multiple windows each special 'flippable' window surface is surely tied to a specific window and becomes invalid if that window is deleted. Making it a property should make this tight relationship between a specific window and a specific flippable surface clearer.
under the old system I used to always get my display surface straight from calling .set_mode()
and I imagine many people did and won't particularly miss .get_surface()
when switching over.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good, the new API makes sense. Maybe as a property it could be moved above the classmethod in the docs, but that's getting deprecated soon enough so maybe doesn't matter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm skeptical of this, I've been slowly thinking about why off an on for a while.
We need to enforce separation of software rendering and hardware rendering, because if we don't SDL will throw lots of sometimes unclear errors.
With this change people don't have to "opt in" to using a display surface, from their perspective the display surface will always be there. Since it's a property it implies there isn't an action to get it, I feel that properties imply that the attribute is always present.
get_surface
also has the advantage of having a very similar semantic to the existing pygame.display.get_surface
I agree with the current system not enforcing a clear distinction between hardware and software rendering, but IMO |
That's an intriguing idea. I'd suggest SurfaceWindow and RendererWindow as the names. We'd also need OpenGLWindow. (Potentially VulkanWindow and GPUWindow (SDL GPU API coming to SDL3) in the future) |
I know
get_surface
was added with similarity topygame.display
in mind, but I think having this as a property instead can make things easier and neater for users of this API.With this, the users would not need to keep track of surface of a window in a separate variable