View Full Version : Classes + CL_Font_System

05-22-2013, 05:21 PM

I have been playing around with the code from the external tutorials. Everything works smoothly. Now im trying to figure out how to use the CL_Font_System. Is there a way to set the font system somehow global so i can draw text to screen from any of my classes?

Or do i need to init the font system in the start of my main loop and use somekind of pointers to just be able to use system_font.draw_text(gc, 100, 100, "Hello World!"); from inside my classes?

Sorry for the stupid question if it is my inferior cpp knowledge, its something like seven years since i coded something with cpp.


05-22-2013, 09:44 PM
The easiest way is a global pointer, that points to the fonts that you created before the main loop.

I prefer to create a "GameContext" class that contains global variables, and I pass it around. It contains a copy of CL_GraphicContext, CL_Sprites, CL_Images, a pointer to the main "world" class).

There are other ways. Depending if you are coding for yourself or other programmers

05-25-2013, 07:46 AM
Uh, just found one example from clanlib package that helped me with the answer i was looking for. Hooray.