Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
games.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_gui
3/// This macro runs three "games" that each nicely illustrate the graphics capabilities of ROOT.
4/// Thanks to the clever usage of TTimer objects it looks like they are all executing in parallel (emulation of
5/// multi-threading). It uses the small classes generated in $ROOTSYS/test/Hello, Aclock, Tetris
6///
7/// \macro_code
8///
9/// \author Valeriy Onuchin
10
11#ifndef __RUN_GAMES__
12
13void games()
14{
15 gSystem->Load("libGui");
16 Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0;
17 Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
18 if (st1 == -1) {
19 printf("===>The $(ROOTSYS)/test/Aclock library failed to load\n");
20 }
21 Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
22 if (st2 == -1) {
23 printf("===>The $(ROOTSYS)/test/Hello library failed to load\n");
24 }
25 Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
26 if (st3 == -1) {
27 printf("===>The $(ROOTSYS)/test/Tetris library failed to load\n");
28 }
29 if (st1 || st2 || st3) {
30 printf("ERROR: at least one of the shared libs in $ROOTSYS/test didn't load properly\n");
31 return;
32 }
33 gROOT->ProcessLine("#define __RUN_GAMES__ 1");
34
35 gInterpreter->AddIncludePath("${ROOTSYS}/test");
36
37 // Add this for CLING not to complain
38 gROOT->ProcessLine("#include \"Hello.h\"");
39 gROOT->ProcessLine("#include \"Aclock.h\"");
40 gROOT->ProcessLine("#include \"Tetris.h\"");
41
42 gROOT->ProcessLine("#include \"games.C\"");
43 gROOT->ProcessLine("rungames()");
44 gROOT->ProcessLine("#undef __RUN_GAMES__");
45}
46
47#else
48
49class Hello;
50class Aclock;
51class Tetris;
52
53void rungames()
54{
55 // run the dancing Hello World
56 Hello *hello = new Hello();
57
58 // run the analog clock
59 Aclock *clock = new Aclock();
60
61 // run the Tetris game
62 Tetris *tetris = new Tetris();
63}
64
65#endif
std::string hello(std::string who, std::string msg)
Definition FunModule.C:5
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gInterpreter
#define gROOT
Definition TROOT.h:417
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1872