Main Page | Namespace List | Class List | File List | Class Members | File Members

engine_base.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   NGT (Neopontec Gaming Toolkit                                         *
00003  *   Distributed under the terms of the GNU LGPL License                   *
00004  *   Copyright (C) 2005 by Hector Blanco de Frutos                         *
00005  *   hectorblanco@neopontec.com                                            *
00006  *   Refer to the LICENSE file to read the full license agreement          *
00007  ***************************************************************************/
00008 
00009 #include "engine_base.h"
00010 
00011 void NGT_Engine::initialize(SDL_Surface *&surf){
00012         
00013         //-------------------------------------------------------------------
00014         // Set the engine version
00015         version = "0.1.0";
00016         // Show version information
00017         printf("\nUsing 'Neopontec Gaming Toolit' - %s\n", version.c_str());
00018         printf("Copyright (c) Hector Blanco de Frutos. 2005-2006\n");
00019         printf("Licensed under the terms of the LGPL license\n\n");
00020         
00021         //------------------------------------------------------------------
00022         
00023         // Initialize SDL
00024     printf("*NGT_Engine.initialize: Starting SDL\n");
00025     if (SDL_Init (SDL_INIT_AUDIO | SDL_INIT_VIDEO) < 0)
00026     {   
00027         printf("*NGT_Engine.initialize: ERROR starting SDL: %s.\n" , SDL_GetError());
00028         exit (1);
00029     }
00030     // Initialize SDL_Mixer
00031     
00032     switch(machine_target){
00033                 case NGT_MACHINE_GENERIC:
00034                         printf("*NGT_Engine.initialize: Starting SDL_mixer\n");
00035                     if(Mix_OpenAudio(audio_frequency, audio_mode, 2, audio_buffer) < 0)
00036                         {
00037                                 printf("*NGT_Engine.initialize: Warning: Couldn't set audio mode - Reason: %s\n", SDL_GetError());
00038                         }
00039                         break;
00040                 case NGT_MACHINE_GP2X:
00041                         printf("*NGT_Engine.initialize: Starting GP2X SDL_mixer\n");
00042                         if(Mix_OpenAudio(audio_frequency, audio_mode, 2, 128) < 0)
00043                         {
00044                                 printf("*NGT_Engine.initialize: WARNING: Couldn't set GP2X audio mode - Reason: %s\n", SDL_GetError());
00045                         }
00046                         break;
00047     }
00048     
00049     switch(machine_target){
00050                 case NGT_MACHINE_GENERIC:
00051                         //Initialize main game surface
00052                         printf("*NGT_Engine.initialize: Creating main SDL surface\n");
00053                     surf = SDL_SetVideoMode (video_res_w, video_res_h, video_bpp, SDL_SWSURFACE | SDL_DOUBLEBUF);
00054                     if (surf == NULL)
00055                     {
00056                         printf("*NGT_Engine.initialize: ERROR while creating main SDL Surface. \n");
00057                     }
00058                     break;
00059                 case NGT_MACHINE_GP2X:
00060                         //Initialize main game surface
00061                         printf("*NGT_Engine.initialize: Creating main GP2X SDL surface\n");
00062                     surf = SDL_SetVideoMode (320, 240, video_bpp, SDL_HWSURFACE);
00063                     if (surf == NULL)
00064                     {
00065                         printf("*NGT_Engine.initialize: ERROR while creating main GP2X SDL Surface. \n");
00066                     }
00067                         break;
00068     }
00069     
00070     printf("*NGT_Engine.initialize: Starting SDL_ttf\n");
00071     if( TTF_Init() == -1 ) {
00072         printf("*NGT_Engine.initialize: ERROR starting SDL_ttf - Reason: %s\n", TTF_GetError());
00073         exit(2);
00074         }
00075 }
00076 
00077 void NGT_Engine::finalize(){ 
00078     switch(machine_target){
00079                 case NGT_MACHINE_GENERIC:
00080                         printf("*NGT_Engine.finalize: NGT_MACHINE_GENERIC: Finalyzing the toolkit\n");
00081                         break;
00082                 case NGT_MACHINE_GP2X:
00083                         printf("*NGT_Engine.finalize: NGT_MACHINE_GP2X: Finalyzing the toolkit\n");
00084                                 // GP2X: Exit to the console menu
00085                                 printf("*NGT_Engine.finalize: NGT_MACHINE_GP2X: Exit to console menu\n");
00086    
00087                                 chdir("/usr/gp2x");
00088                                 execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
00089                         break;
00090     }           
00091 
00092 }

Generated on Wed Feb 1 00:07:07 2006 for Neopntec Gaming Toolkit - API reference by  doxygen 1.4.4