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 multi-threading).
5/// 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 macro games will try to build the Aclock library\n");
20 if (UNIX)
21 gSystem->Exec("(cd $ROOTSYS/test; make Aclock)");
22 else
23 gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)");
24
25 st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
26 }
27 Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
28 if (st2 == -1) {
29 printf("===>The macro games will try to build the Hello library\n");
30 if (UNIX)
31 gSystem->Exec("(cd $ROOTSYS/test; make Hello)");
32 else
33 gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)");
34
35 st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
36 }
37 Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
38 if (st3 == -1) {
39 if (UNIX) {
40 printf("===>The macro games will try to build the Tetris library\n");
41 gSystem->Exec("(cd $ROOTSYS/test; make Tetris)");
42 } else {
43 gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)");
44 }
45 st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
46 }
47 if (st1 || st2 || st3) {
48 printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n");
49 return;
50 }
51 gROOT->ProcessLine("#define __RUN_GAMES__ 1");
52
53 //Add this for CLING not to complain
54 gROOT->ProcessLine("#include \"Hello.h\"");
55 gROOT->ProcessLine("#include \"Aclock.h\"");
56 gROOT->ProcessLine("#include \"Tetris.h\"");
57
58 gROOT->ProcessLine("#include \"games.C\"");
59 gROOT->ProcessLine("rungames()");
60 gROOT->ProcessLine("#undef __RUN_GAMES__");
61}
62
63#else
64
65class Hello;
66class Aclock;
67class Tetris;
68
69void rungames()
70{
71 // run the dancing Hello World
72 Hello *hello = new Hello();
73
74 // run the analog clock
75 Aclock *clock = new Aclock();
76
77 // run the Tetris game
78 Tetris *tetris = new Tetris();
79}
80
81#endif
std::string hello(std::string who, std::string msg)
Definition FunModule.C:5
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:555
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:653
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1857