Panda3D
config_rocket.cxx
1 // Filename: config_rocket.cxx
2 // Created by: rdb (04Nov11)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_rocket.h"
16 #include "rocketFileInterface.h"
17 #include "rocketInputHandler.h"
18 #include "rocketRegion.h"
19 #include "rocketSystemInterface.h"
20 
21 #include "pandaSystem.h"
22 #include "dconfig.h"
23 #include "default_font.h"
24 
25 // This is defined by both Panda and Rocket.
26 #define Factory RocketFactory
27 #include <Rocket/Core.h>
28 #undef Factory
29 
30 Configure(config_rocket);
31 NotifyCategoryDef(rocket, "");
32 
33 ConfigureFn(config_rocket) {
34  init_librocket();
35 }
36 
37 ////////////////////////////////////////////////////////////////////
38 // Function: init_librocket
39 // Description: Initializes the library. This must be called at
40 // least once before any of the functions or classes in
41 // this library can be used. Normally it will be
42 // called by the static initializers and need not be
43 // called explicitly, but special cases exist.
44 ////////////////////////////////////////////////////////////////////
45 void
46 init_librocket() {
47  static bool initialized = false;
48  if (initialized) {
49  return;
50  }
51  initialized = true;
52 
53  RocketInputHandler::init_type();
54  RocketRegion::init_type();
55 
56  if (rocket_cat->is_debug()) {
57  rocket_cat->debug() << "Initializing libRocket library.\n";
58  }
59 
61  Rocket::Core::SetFileInterface(fi);
62 
64  Rocket::Core::SetSystemInterface(si);
65 
66  Rocket::Core::Initialise();
67 
68  // Register that we have the libRocket system.
70  ps->add_system("libRocket");
71 
72 #ifdef COMPILE_IN_DEFAULT_FONT
73 #ifdef HAVE_FREETYPE
74  // Load Panda's default compiled-in freetype font (Perspective Sans).
75  Rocket::Core::FontDatabase::LoadFontFace(default_font_data, default_font_size);
76 #endif
77 #endif
78 }
static PandaSystem * get_global_ptr()
Returns the global PandaSystem object.
This class is used as a namespace to group several global properties of Panda.
Definition: pandaSystem.h:29
void add_system(const string &system)
Intended for use by each subsystem to register itself at startup.
This is an implementation of SystemInterface that redirects the log output to Panda&#39;s notify system...
Implementation of FileInterface to allow libRocket to read files from the virtual file system...