Logo ROOT  
Reference Guide
No Matches
games.C File Reference

Detailed Description

This macro runs three "games" that each nicely illustrate the graphics capabilities of ROOT.

Thanks to the clever usage of TTimer objects it looks like they are all executing in parallel (emulation of multi-threading). It uses the small classes generated in $ROOTSYS/test/Hello, Aclock, Tetris

#ifndef __RUN_GAMES__
void games()
Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0;
Int_t st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
if (st1 == -1) {
printf("===>The macro games will try to build the Aclock library\n");
if (UNIX)
gSystem->Exec("(cd $ROOTSYS/test; make Aclock)");
gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Aclock.dll)");
st1 = gSystem->Load("$(ROOTSYS)/test/Aclock");
Int_t st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
if (st2 == -1) {
printf("===>The macro games will try to build the Hello library\n");
if (UNIX)
gSystem->Exec("(cd $ROOTSYS/test; make Hello)");
gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Hello.dll)");
st2 = gSystem->Load("$(ROOTSYS)/test/Hello");
Int_t st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
if (st3 == -1) {
if (UNIX) {
printf("===>The macro games will try to build the Tetris library\n");
gSystem->Exec("(cd $ROOTSYS/test; make Tetris)");
} else {
gSystem->Exec("(cd %ROOTSYS%\\test && nmake -f Makefile.win32 Tetris.dll)");
st3 = gSystem->Load("$(ROOTSYS)/test/Tetris");
if (st1 || st2 || st3) {
printf("ERROR: one of the shared libs in $ROOTSYS/test didn't load properly\n");
gROOT->ProcessLine("#define __RUN_GAMES__ 1");
//Add this for CLING not to complain
gROOT->ProcessLine("#include \"Hello.h\"");
gROOT->ProcessLine("#include \"Aclock.h\"");
gROOT->ProcessLine("#include \"Tetris.h\"");
gROOT->ProcessLine("#include \"games.C\"");
gROOT->ProcessLine("#undef __RUN_GAMES__");
class Hello;
class Aclock;
class Tetris;
void rungames()
// run the dancing Hello World
Hello *hello = new Hello();
// run the analog clock
Aclock *clock = new Aclock();
// run the Tetris game
Tetris *tetris = new Tetris();
std::string hello(std::string who, std::string msg)
Definition FunModule.C:5
int Int_t
Definition RtypesCore.h:45
bool Bool_t
Definition RtypesCore.h:63
#define gROOT
Definition TROOT.h:406
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
virtual const char * GetName() const
Returns name of object.
Definition TNamed.h:47
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:654
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Definition TSystem.cxx:1853
Valeriy Onuchin

Definition in file games.C.