Pass the SpriteFont, please.

This is probably more of a C question than RayLib question but here goes...

I am able to successfully load and use my font within Main(). However, I wish to call some functions to display text but of course the font is not visible from those functions. I have failed to successfully define and load the font from before Main() in an attempt to make it globally visible. I have failed to successfully pass the font to the functions as a parameter. It seems silly to me to load it (and unload it?) within each function. What is the correct way to handle this? (I know I have likely done a miserable job in explaining my question). Thanks!

Comments

  • Just declare Spritefont myfont; before main()

    Inside main(), after InitWindow(), load the font:
    myfont = LoadSpriteFont("myfont.ttf");

    myfont is visible from all external functions.
  • Thank you! :)
Sign In or Register to comment.