Results 1 to 3 of 3

Thread: Classes + CL_Font_System

  1. #1
    Peasant
    Join Date
    May 2013
    Location
    Finland
    Posts
    6

    Default Classes + CL_Font_System

    Heya.

    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.


  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    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

  3. #3
    Peasant
    Join Date
    May 2013
    Location
    Finland
    Posts
    6

    Default

    Uh, just found one example from clanlib package that helped me with the answer i was looking for. Hooray.
    Last edited by aNSA; 05-26-2013 at 08:37 PM.

Similar Threads

  1. Socket helper classes
    By BigBMan in forum Proton SDK
    Replies: 4
    Last Post: 12-30-2010, 05:45 AM
  2. Question about moving from CL_Surface to 2.1 classes
    By Nightwind0 in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 01-20-2010, 06:00 PM
  3. Race condition in network classes
    By Niklas in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 09-22-2006, 12:11 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •