application.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Reality Rift Studios                            *
00003  *   http://www.realityrift.com  -  mattias@realityrift.com                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #ifndef neo_application_application_h
00022 #define neo_application_application_h
00023 
00024 #include "base.h"
00025 #include "../core/array.h"
00026 #include "../core/timer.h"
00027 #include "../core/pointer.h"
00028 
00029 namespace neo {
00030 namespace render { class Device; class Resolution; }
00031 namespace input { class Device; class Event; }
00032 namespace gui { NEO_DECLARE_SMARTPOINTER( Font ) }
00033 namespace application {
00034 
00035 class WindowEventListener;
00036 
00038 
00040 class Application
00041 {
00042     public:
00043 
00045 
00047                                                             Application( const std::string& name );
00048 
00050     virtual                                                ~Application();
00051 
00053 
00054     void                                                    start();
00055 
00057 
00058     void                                                    stop();
00059 
00061 
00063     static Application*                                     createApplication();
00064 
00065     protected:
00066 
00068 
00070     virtual void                                            initialize();
00071 
00073 
00080     void                                                    run();
00081 
00083 
00084     virtual void                                            shutdown();
00085 
00087 
00088     bool                                                    isInitialized() const;
00089 
00091 
00092     virtual void                                            processInput();
00093 
00095 
00097     virtual void                                            updateFrame( float deltaTime ) = 0;
00098 
00100 
00101     virtual void                                            renderFrame() = 0;
00102 
00104 
00105     virtual void                                            input( const input::Event* p_event );
00106 
00108 
00110     render::Resolution*                                     getPrevResolution( const render::Resolution& res );
00111 
00113 
00116     render::Resolution*                                     getNextResolution( const render::Resolution& res, bool same = false );
00117     
00119     std::string                                             _name;
00120 
00122     bool                                                    _useSetupDialog;
00123     
00125     bool                                                    _run;
00126 
00128     int                                                     _fixedUpdate;
00129 
00131     core::Timer                                             _timer;
00132 
00134     float                                                   _timeacc;
00135 
00137     render::Device*                                         _p_deviceRender;
00138 
00140     input::Device*                                          _p_deviceInput;
00141     
00143     core::Array< unsigned int >                             _programPriority;
00144     
00146     core::Array< unsigned int >                             _shaderPriority;
00147 
00149     core::Array< render::Resolution >                       _resAvailable;
00150     
00152     WindowEventListener*                                    _p_listenerWindow;
00153 
00155     core::Timer                                             _timerFPS;
00156 
00158     unsigned int                                            _numFrames;
00159 
00161     float                                                   _fps;
00162 
00164     bool                                                    _showFPS;
00165 
00167     gui::FontPtr                                            _p_fontDefault;
00168 
00169     private:
00170 
00171     bool                                                    _initialized;
00172 
00173     friend int ::real_main();
00174 };
00175 
00176 #if NEO_PLATFORM_WINDOWS && NEO_COMPILER_GCC && !defined( _CONSOLE )
00177 
00178 #define _neo_application_implement( T, name ) neo::application::Application* neo::application::Application::createApplication() { return new T( name ); } \
00179 extern "C" { int __stdcall WinMain( HINSTANCE, HINSTANCE, const char*, int ); } \
00180 int __stdcall (*pfnExtWinMain)( HINSTANCE, HINSTANCE, const char*, int ) = WinMain;
00181 
00182 #else
00183 
00184 #define _neo_application_implement( T, name ) neo::application::Application* neo::application::Application::createApplication() { return new T( name ); }
00185 
00186 #endif
00187 
00188 }
00189 }
00190 
00191 #endif

Generated on Sat Feb 17 20:50:47 2007 for NeoEngine 2 - Evolution by  doxygen 1.5.1