Surface from Texture.

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
User avatar
Vladya
Regular
Posts: 34
Joined: Sun Sep 20, 2020 3:16 am
Github: NyashniyVladya
Contact:

Surface from Texture.

#1 Post by Vladya »

Good afternoon!
I think it would be great if in new versions of Ren'Py it would be possible to get a Surface object from any texture (TextureGrid, Surface, Texture).

Why do I need it?
Mainly to be able to work directly with pixels in cython, getting mapped via PySurface_AsSurface without having to worry about what render mode is enabled. This can also be useful in other situations.

For example, recently I was making code that allows me to save any Displayable as an external .png file (this can be useful if the player wants to put a picture he likes on his avatar, desktop, etc.). There's no problem with ImageBase. I just pass it to image_save_unscaled and... And that's it.
But for other displayable objects, I had to write a hack, getting Surface via renpy.display.draw.screenshot and resizing it to the right size. But of course, this is not a solution, because in this case the quality suffers greatly, which depends directly on the physical resolution of the screen.

In fact, you don't even have to write new code for that. I need a method similar to renpy.display.draw.screenshot, but that doesn't place pixels on a fixed rectangle, but returns a Surface object in its original size.

P.S.: I understand that you now have a lot of work with the 7.4.0 release and, by no means, I'm not rushing it. I just wanted to express an idea that has been on my mind for quite some time.
P.P.S.: I am just a beginner and far from an expert, so I admit that maybe this possibility already exists. If so, please excuse me and suggest the right method.

User avatar
PyTom
Ren'Py Creator
Posts: 16088
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Surface from Texture.

#2 Post by PyTom »

I honestly don't think this is something I want to support, just because it would mean an entire second world - one where textures are loaded onto the GPU unscaled. I'd be happy to add something that can render things scaled, and then give you the pixels - a supported version of what your'e doing now.

But I think adding a second path through the GPU where things are not being scaled isn't really something I'd like to do. It would interfere too much with things like Render caching, and is fundamentally enough work to implement, debug, and keep supported that I don't think that would be worth doing.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

Post Reply

Who is online

Users browsing this forum: No registered users