ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
gui
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
13
void
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
gROOT
->ProcessLine(
"#include \"games.C\""
);
53
gROOT
->ProcessLine(
"rungames()"
);
54
gROOT
->ProcessLine(
"#undef __RUN_GAMES__"
);
55
}
56
57
#else
58
59
class
Hello;
60
class
Aclock;
61
class
Tetris;
62
63
void
rungames()
64
{
65
// run the dancing Hello World
66
Hello *
hello
=
new
Hello();
67
68
// run the analog clock
69
Aclock *clock =
new
Aclock();
70
71
// run the Tetris game
72
Tetris *tetris =
new
Tetris();
73
}
74
75
#endif
hello
std::string hello(std::string who, std::string msg)
Definition:
FunModule.C:5
gROOT
#define gROOT
Definition:
TROOT.h:344
TSystem::Load
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition:
TSystem.cxx:1766
Int_t
int Int_t
Definition:
RtypesCore.h:41
Bool_t
bool Bool_t
Definition:
RtypesCore.h:59
gSystem
R__EXTERN TSystem * gSystem
Definition:
TSystem.h:545
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition:
TNamed.h:51
TSystem::Exec
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition:
TSystem.cxx:657
printf
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)