Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Root.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TSGL - Teddy Space Game Library
00004     Copyright (C) 2002 Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Root.cpp,v 1.1 2002/01/08 20:47:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "config.h"
00026 #include "Teddy/SpaceGame/Root.h"
00027 #include "Teddy/SysSupport/Messages.h"
00028 #include "Teddy/SysSupport/Teddy.h"
00029 #include <cstdlib>
00030 #include <cstring>
00031 using namespace Teddy::SysSupport;
00032 
00033 
00034 namespace Teddy     {
00035 namespace SpaceGame {
00036 
00037 
00039 Root::Root( int argc, char **argv ){
00040 #   if !defined( USE_TINY_GL )
00041     screen_width  = 800;
00042     screen_height = 600;
00043 #   else
00044     screen_width  = 400;
00045     screen_height = 300;
00046 #   endif
00047 
00048     teddy_init  ();
00049     parseOptions( argc, argv );
00050 
00051     action_manager   = new ActionManager  ( this );
00052     audio_manager    = new AudioManager   ( this );
00053     user_interface   = new UserInterface  ( this );  //  Opens view
00054     object_manager   = new ObjectManager  ( this );  //  Creates scene and camera
00055     simulation_timer = new SimulationTimer( this );
00056     event_manager    = new EventManager   ( this );  //  Initializes controls
00057 
00058     object_manager  ->addObjects   ();  //  Add objects to scene
00059     user_interface  ->addComponents();  //  Create UserInterface
00060     simulation_timer->start        ();  //  Start simulation timer
00061     audio_manager   ->playHyper    ();
00062     user_interface  ->enterRunLoop ();  //  Enter run loop
00063 
00064 //  init_msg( "CVertex::Array..." );
00065 //  CVertex::Array.Init();
00066 //  CVertex::Array.EnableVertexArray();
00067 //  CVertex::Array.EnableNormalArray();
00068 //  CVertex::Array.EnableTextureCoordArray();
00069 }
00070 
00071 
00073 void Root::parseOptions( int argc, char **argv ){
00074     int  i;
00075 
00076 #   if !defined( USE_TINY_GL )
00077     setOptions( RO_AUDIO | RO_MULTI_WINDOW | RO_HUD | RO_SCANNER );
00078 #   else
00079     setOptions( RO_AUDIO | RO_HUD );
00080 #   endif
00081 
00082     for( i=1; i<argc; i++ ){
00083         if( strcmp(argv[i],"--fullscreen") == 0 ){
00084             enableOptions( RO_FULLSCREEN );
00085         }else if( strcmp(argv[i],"--width") == 0 ){
00086             if( argc > i+1 ){
00087                 screen_width = atoi( argv[i+1] );
00088             }else{
00089                 printf( "width needs parameter\n" );
00090             }
00091         }else if( strcmp(argv[i],"--height") == 0 ){
00092             if( argc > i+1 ){
00093                 screen_height = atoi( argv[i+1] );
00094             }else{
00095                 printf( "height needs parameter\n" );
00096             }
00097         }else if( strcmp(argv[i],"--multi-window") == 0 ){
00098             enableOptions( RO_MULTI_WINDOW );
00099         }else if( strcmp(argv[i],"--no-multi-window") == 0 ){
00100             disableOptions( RO_MULTI_WINDOW );
00101         }else if( strcmp(argv[i],"--audio") == 0 ){
00102             enableOptions( RO_AUDIO );
00103         }else if( strcmp(argv[i],"--no-audio") == 0 ){
00104             disableOptions( RO_AUDIO );
00105         }else if( strcmp(argv[i],"--hud") == 0 ){
00106             enableOptions( RO_HUD );
00107         }else if( strcmp(argv[i],"--no-hud") == 0 ){
00108             disableOptions( RO_HUD );
00109         }else if( strcmp(argv[i],"--scanner") == 0 ){
00110             enableOptions( RO_SCANNER );
00111         }else if( strcmp(argv[i],"--no-scanner") == 0 ){
00112             disableOptions( RO_SCANNER );
00113         }else if( strcmp(argv[i],"--no-cabin") == 0 ){
00114             disableOptions( RO_CABIN );
00115         }else if( strcmp(argv[i],"--debug") == 0 ){
00116             enableOptions( RO_DEBUG );
00117         }
00118     }
00119 
00120     //  Print initialization messages
00121     if( isEnabled(RO_AUDIO) == true ){
00122         printf( "audio enabled\n" );
00123     }else{
00124         printf( "audio disabled\n" );
00125         
00126     }
00127 
00128     if( isEnabled(RO_MULTI_WINDOW) ){
00129         init_msg( "multiple windows enabled" );
00130     }else{
00131         init_msg( "multiple windows disabled" );
00132     }
00133 
00134     if( isEnabled(RO_CABIN) == true ){
00135         init_msg( "cabin enabled" );
00136     }else{
00137         init_msg( "cabin disabled" );
00138     }
00139 
00140     if( isEnabled(RO_FULLSCREEN) == true ){
00141         init_msg( "fullscreen enabled" );
00142     }else{
00143         init_msg( "fullscreen disabled" );
00144     }
00145 
00146     if( isEnabled(RO_DEBUG) == true ){
00147         init_msg( "debug enabled" );
00148     }else{
00149         init_msg( "debug disabled" );
00150     }
00151 }
00152 
00153 
00154 ActionManager *Root::getActionManager(){
00155     return action_manager;
00156 }
00157 
00158 
00159 AudioManager *Root::getAudioManager(){
00160     return audio_manager;
00161 }
00162 
00163 
00164 EventManager *Root::getEventManager(){
00165     return event_manager;
00166 }
00167 
00168 
00169 ObjectManager *Root::getObjectManager(){
00170     return object_manager;
00171 }
00172 
00173 
00174 SimulationTimer *Root::getSimulationTimer(){
00175     return simulation_timer;
00176 }
00177 
00178 
00179 UserInterface *Root::getUserInterface(){
00180     return user_interface;
00181 }
00182 
00183 
00184 int Root::getScreenWidth(){
00185     return screen_width;
00186 }
00187 
00188 
00189 int Root::getScreenHeight(){
00190     return screen_height;
00191 }
00192 
00193 
00194 };  //  namespace SpaceGame
00195 };  //  namespace Teddy
00196