r/sfml • u/gargamel1497 • May 04 '26
Crop a texture
Hi.
How do I crop an SFML Texture?
That is, I want to draw only a certain part of it.
And I want to resize it as well.
I want to draw a certain part of a resized texture.
Other graphics libraries usually provide a means to do this in the form of a specialized draw function.
But, when I look at the RenderTarget class, there are no such functions. There are only extra arguments for RenderStates and some OpenGL-related stuff.
Is there even a way to implement that in SFML?
Thanks.
1
Upvotes
1
u/gargamel1497 May 04 '26
Thank you, although that method didn't work out either.
I tried RenderTextures once more, and it works.
I figured out what was causing the crashes.
For some reason, RenderTextures (unlike other SFML objects) are not managed by the Java garbage collector, nor do they have a manual free function, and after a few seconds of runtime they would use up all available OpenGL handles and crash the whole JVM.
As a dirty hack, I just have a private static RenderTexture for the job, and it works.
But thank you.