Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing text on an image and saving the image  (Read 1787 times)

0 Members and 1 Guest are viewing this topic.

alexanderzhirov

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Blog
    • Email
Drawing text on an image and saving the image
« on: April 27, 2022, 07:23:58 am »
I'm trying to output text to an image. It is not possible to output text by coordinates (x,y) and after saving the image turns out to be mirrored and inverted. I don't understand what I'm doing wrong?

(click to show/hide)

« Last Edit: April 27, 2022, 07:28:21 am by alexanderzhirov »

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Drawing text on an image and saving the image
« Reply #1 on: April 27, 2022, 07:33:11 am »
Apparently after drawing into a render texture, you have to call it's .display() method, otherwise the texture is left in an undefined state and can appear upside down.

https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1RenderTexture.php#af92886d5faef3916caff9fa9ab32c555

alexanderzhirov

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Blog
    • Email
Re: Drawing text on an image and saving the image
« Reply #2 on: April 27, 2022, 07:57:32 am »
Apparently after drawing into a render texture, you have to call it's .display() method, otherwise the texture is left in an undefined state and can appear upside down.

Yes, it's worked out now! Thanks!

(click to show/hide)

It remains to understand how to correctly output the text according to the coordinates I need?

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Drawing text on an image and saving the image
« Reply #3 on: April 27, 2022, 10:31:53 am »
The Text object has a setPosition() that works just like for sprites. It controls where the top left corner of the text will be placed (default is 0,0).

 

anything