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

Author Topic: Where is glGenTexture called?  (Read 212 times)

0 Members and 1 Guest are viewing this topic.

nagimar

  • Newbie
  • *
  • Posts: 45
    • View Profile
Where is glGenTexture called?
« on: May 12, 2025, 10:37:37 am »
Hi!
In the class sf::Font, call the update function here :

Code: [Select]
page.texture.update(&m_pixelBuffer[0], w, h, x, y);
But I don't find where you call glGenTexture, the update function from the texture class doesn't call glGenTexture.

Is this normal ?

This is the code of the SFML 2.5.1.
« Last Edit: May 12, 2025, 10:46:26 am by eXpl0it3r »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11203
    • View Profile
    • development blog
    • Email
Re: Where is glGenTexture called?
« Reply #1 on: May 12, 2025, 10:48:31 am »
glGenTexture is called from within the sf::Texture implementation, see here: https://github.com/SFML/SFML/blob/2.6.2/src/SFML/Graphics/Texture.cpp#L167

When a new page is inserted into the sf::Font, then a new texture is created and glGenTexture is called.

PS: I've edited your title, since "I have a question" is quite a bad subject title, see also: https://en.sfml-dev.org/forums/index.php?topic=5559.0
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nagimar

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Where is glGenTexture called?
« Reply #2 on: May 12, 2025, 12:44:53 pm »
Ok but where do you call create on the texture font page ?

I only see the call of update, but not the call of create.


eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11203
    • View Profile
    • development blog
    • Email
Re: Where is glGenTexture called?
« Reply #3 on: May 12, 2025, 01:11:40 pm »
loadPage creates an instance of the Page struct which default initializes the texture: https://github.com/SFML/SFML/blob/2.6.2/src/SFML/Graphics/Font.cpp#L571

A constructor doesn't always need to be explicitly called.
Official FAQ: https://www.sfml-dev.org/faq/
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

nagimar

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Where is glGenTexture called?
« Reply #4 on: May 12, 2025, 01:26:33 pm »
Ah ok it's in loadPage. Thanks.