brought to compatibility with tests
This commit is contained in:
		
							parent
							
								
									dcf68651ae
								
							
						
					
					
						commit
						45282000b2
					
				
					 8 changed files with 58 additions and 37 deletions
				
			
		|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: Application.hpp,v 1.7 2005/03/15 19:22:07 cozman Exp $
 | //  $Id: Application.hpp,v 1.8 2005/05/15 02:51:10 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #ifndef PHOTON_APPLICATION_HPP | #ifndef PHOTON_APPLICATION_HPP | ||||||
| #define PHOTON_APPLICATION_HPP | #define PHOTON_APPLICATION_HPP | ||||||
|  | @ -63,7 +63,7 @@ public: | ||||||
| 
 | 
 | ||||||
| // Group: API Initialization
 | // Group: API Initialization
 | ||||||
| private: | private: | ||||||
|     util::VersionInfo initPhysFS(const char* arg0); |     util::VersionInfo initPhysFS(); | ||||||
| 
 | 
 | ||||||
| private: | private: | ||||||
|     // version number for photon
 |     // version number for photon
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: Log.hpp,v 1.5 2005/03/15 19:12:59 cozman Exp $
 | //  $Id: Log.hpp,v 1.6 2005/05/15 02:51:10 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #ifndef PHOTON_LOG_HPP | #ifndef PHOTON_LOG_HPP | ||||||
| #define PHOTON_LOG_HPP | #define PHOTON_LOG_HPP | ||||||
|  | @ -21,12 +21,9 @@ namespace photon | ||||||
| {  | {  | ||||||
| 
 | 
 | ||||||
| // Class: Log
 | // Class: Log
 | ||||||
| //  <Singleton> log class for photon, Log passes all messages to any attached 
 | //  Log class for photon, Log passes all messages to any attached <LogSinks>,
 | ||||||
| //  <LogSinks>, which can then take care of any output which is desired.
 | //  which can then take care of any output which is desired.
 | ||||||
| //
 | class Log | ||||||
| // Parent:
 |  | ||||||
| //  <Singleton>
 |  | ||||||
| class Log : public util::Singleton<Log> |  | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| // Group: (Con/De)structors
 | // Group: (Con/De)structors
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: entrypoint.hpp,v 1.4 2005/03/15 19:22:07 cozman Exp $
 | //  $Id: entrypoint.hpp,v 1.5 2005/05/15 02:51:10 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| #ifndef PHOTON_ENTRYPOINT_HPP | #ifndef PHOTON_ENTRYPOINT_HPP | ||||||
|  | @ -28,30 +28,34 @@ | ||||||
| namespace photon | namespace photon | ||||||
| { | { | ||||||
| 
 | 
 | ||||||
| // function which does all the work of MAINCLASS
 | // function which does all the work of ENTRYPOINT
 | ||||||
| template<class App> | template<class App> | ||||||
| int mainclass(int argc, const char** argv) | int mainclass(int argc, const char** argv) | ||||||
| { | { | ||||||
|  |     Log log; | ||||||
|  |     log.addSink(LogSinkPtr(new photon::ConsoleSink("out"))); | ||||||
|  |      | ||||||
|     try |     try | ||||||
|     { |     { | ||||||
|  |         App::setInitOptions(argv[0]); | ||||||
|  |          | ||||||
|         App app; |         App app; | ||||||
|         StrVec args; |         StrVec args; | ||||||
|         for(int i=0; i < argc; ++i) |         for(int i=0; i < argc; ++i) | ||||||
|         { |         { | ||||||
|             args.push_back(argv[i]); |             args.push_back(argv[i]); | ||||||
|         } |         } | ||||||
|         App::setInitOptions(argv[0]); |  | ||||||
| 
 | 
 | ||||||
|         return app.main(args); |         return app.main(args); | ||||||
|     } |     } | ||||||
|     catch(Exception &e) |     catch(Exception &e) | ||||||
|     { |     { | ||||||
|         Log::getInstance().error() << e; |         log.error() << e; | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|     catch(Error &e) |     catch(Error &e) | ||||||
|     { |     { | ||||||
|         Log::getInstance().critical() << e; |         log.critical() << e; | ||||||
|         return 1; |         return 1; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -13,6 +13,7 @@ | ||||||
| #include "Log.hpp" | #include "Log.hpp" | ||||||
| #include "ResourceManaged.hpp" | #include "ResourceManaged.hpp" | ||||||
| #include "ResourceManager.hpp" | #include "ResourceManager.hpp" | ||||||
|  | #include "audio/AudioCore.hpp" | ||||||
| #include "math/math.hpp" | #include "math/math.hpp" | ||||||
| #include "math/Rect.hpp" | #include "math/Rect.hpp" | ||||||
| #include "math/Vector2.hpp" | #include "math/Vector2.hpp" | ||||||
|  | @ -23,10 +24,9 @@ | ||||||
| #include "util/RandGen.hpp" | #include "util/RandGen.hpp" | ||||||
| #include "util/Timer.hpp" | #include "util/Timer.hpp" | ||||||
| #include "util/FileBuffer.hpp" | #include "util/FileBuffer.hpp" | ||||||
| #include "audio/AudioCore.hpp" | #include "util/filesys/filesys.hpp" | ||||||
| #include "video/Pen.hpp" | #include "video/Pen.hpp" | ||||||
| #include "video/Color.hpp" | #include "video/Color.hpp" | ||||||
| #include "video/VideoCore.hpp" | #include "video/VideoCore.hpp" | ||||||
| #include "util/filesys/filesys.hpp" |  | ||||||
| 
 | 
 | ||||||
| #endif // PHOTON_HPP
 | #endif // PHOTON_HPP
 | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: Application.cpp,v 1.7 2005/04/21 19:30:19 cozman Exp $
 | //  $Id: Application.cpp,v 1.8 2005/05/15 02:50:52 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #include "Application.hpp" | #include "Application.hpp" | ||||||
| 
 | 
 | ||||||
|  | @ -13,12 +13,13 @@ | ||||||
| #include "GL/gl.h" | #include "GL/gl.h" | ||||||
| 
 | 
 | ||||||
| #include <boost/lexical_cast.hpp> | #include <boost/lexical_cast.hpp> | ||||||
| 
 | #include <iostream> | ||||||
| #include "exceptions.hpp" | #include "exceptions.hpp" | ||||||
| #include "Log.hpp" | #include "Log.hpp" | ||||||
| #include "Kernel.hpp" | #include "Kernel.hpp" | ||||||
| #include "AppCore.hpp" | #include "AppCore.hpp" | ||||||
| #include "video/VideoCore.hpp" | #include "video/VideoCore.hpp" | ||||||
|  | #include "audio/AudioCore.hpp" | ||||||
| 
 | 
 | ||||||
| namespace photon | namespace photon | ||||||
| { | { | ||||||
|  | @ -29,10 +30,10 @@ Application::Application() : | ||||||
|     util::VersionInfo physfsReq(1,0,0); // requires PhysFS 1.0.0
 |     util::VersionInfo physfsReq(1,0,0); // requires PhysFS 1.0.0
 | ||||||
|      |      | ||||||
|     // create the singletons
 |     // create the singletons
 | ||||||
|     new Log; |  | ||||||
|     new Kernel; |     new Kernel; | ||||||
|     new AppCore; |     new AppCore; | ||||||
|     new video::VideoCore; |     new video::VideoCore; | ||||||
|  |     new audio::AudioCore; | ||||||
| 
 | 
 | ||||||
|     // StrVec args;
 |     // StrVec args;
 | ||||||
|     // 
 |     // 
 | ||||||
|  | @ -40,8 +41,8 @@ Application::Application() : | ||||||
|     // {
 |     // {
 | ||||||
|     //     args.push_back(argv[i]);
 |     //     args.push_back(argv[i]);
 | ||||||
|     // }
 |     // }
 | ||||||
|      | 
 | ||||||
|     util::ensureVersion("PhysFS", initPhysFS(arg0_.c_str()), physfsReq); |     util::ensureVersion("PhysFS", initPhysFS(), physfsReq); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| Application::~Application() | Application::~Application() | ||||||
|  | @ -51,8 +52,8 @@ Application::~Application() | ||||||
|     // destroy the singletons
 |     // destroy the singletons
 | ||||||
|     AppCore::destroy(); |     AppCore::destroy(); | ||||||
|     video::VideoCore::destroy(); |     video::VideoCore::destroy(); | ||||||
|  |     audio::AudioCore::destroy(); | ||||||
|     Kernel::destroy(); |     Kernel::destroy(); | ||||||
|     Log::destroy(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Application::setInitOptions(const char* arg0) | void Application::setInitOptions(const char* arg0) | ||||||
|  | @ -60,11 +61,11 @@ void Application::setInitOptions(const char* arg0) | ||||||
|     arg0_ = arg0; |     arg0_ = arg0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| util::VersionInfo Application::initPhysFS(const char* arg0) | util::VersionInfo Application::initPhysFS() | ||||||
| { | { | ||||||
|     PHYSFS_Version ver; |     PHYSFS_Version ver; | ||||||
|     PHYSFS_init(arg0); |     PHYSFS_init(arg0_.c_str()); | ||||||
|     PHYSFS_addToSearchPath(arg0,0); |     PHYSFS_addToSearchPath(arg0_.c_str(),0); | ||||||
|     PHYSFS_getLinkedVersion(&ver); |     PHYSFS_getLinkedVersion(&ver); | ||||||
|     return util::VersionInfo(ver.major, ver.minor, ver.patch); |     return util::VersionInfo(ver.major, ver.minor, ver.patch); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: Log.cpp,v 1.7 2005/03/01 07:52:20 cozman Exp $
 | //  $Id: Log.cpp,v 1.8 2005/05/15 02:50:52 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #include "Log.hpp" | #include "Log.hpp" | ||||||
| 
 | 
 | ||||||
|  | @ -22,7 +22,7 @@ Log::Log() | ||||||
| Log::~Log() | Log::~Log() | ||||||
| { | { | ||||||
|     flush(); |     flush(); | ||||||
|     removeSinks();; |     removeSinks(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Log::addSink(LogSinkPtr sink) | void Log::addSink(LogSinkPtr sink) | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: AudioCore.cpp,v 1.4 2005/03/15 18:42:40 cozman Exp $
 | //  $Id: AudioCore.cpp,v 1.5 2005/05/15 02:50:52 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #include "audio/AudioCore.hpp" | #include "audio/AudioCore.hpp" | ||||||
| 
 | 
 | ||||||
|  | @ -19,7 +19,7 @@ namespace audio | ||||||
| 
 | 
 | ||||||
| AudioCore::AudioCore() | AudioCore::AudioCore() | ||||||
| { | { | ||||||
|     util::VersionInfo oalReq(1,0,0);    // requires OpenAL 1.0 (TODO: check?)
 |     util::VersionInfo oalReq(0,0,7);    // requires OpenAL 1.0 (TODO: check?)
 | ||||||
|     util::ensureVersion("OpenAL", initOpenAL(), oalReq); |     util::ensureVersion("OpenAL", initOpenAL(), oalReq); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -42,6 +42,7 @@ std::string AudioCore::getAudioDeviceName() const | ||||||
|     ALCdevice* device (alcGetContextsDevice( alcGetCurrentContext() )); |     ALCdevice* device (alcGetContextsDevice( alcGetCurrentContext() )); | ||||||
|     std::string name ( reinterpret_cast<const char*>( |     std::string name ( reinterpret_cast<const char*>( | ||||||
|                         alcGetString(device, ALC_DEVICE_SPECIFIER)) ); |                         alcGetString(device, ALC_DEVICE_SPECIFIER)) ); | ||||||
|  |                          | ||||||
|     return name; |     return name; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -52,7 +53,7 @@ util::VersionInfo AudioCore::initOpenAL() | ||||||
|     std::stringstream ss;   // stream for parsing version
 |     std::stringstream ss;   // stream for parsing version
 | ||||||
|     std::string junks;      // junk string for parsing
 |     std::string junks;      // junk string for parsing
 | ||||||
|     char junkc;             // junk character for parsing
 |     char junkc;             // junk character for parsing
 | ||||||
|     uint major,minor;       // version numbers
 |     uint major,minor,patch; // version numbers
 | ||||||
| 
 | 
 | ||||||
|     // obtain default device if no deviceName is set, otherwise use deviceName
 |     // obtain default device if no deviceName is set, otherwise use deviceName
 | ||||||
|     device = alcOpenDevice(deviceName_.empty() ? 0 : |     device = alcOpenDevice(deviceName_.empty() ? 0 : | ||||||
|  | @ -75,10 +76,19 @@ util::VersionInfo AudioCore::initOpenAL() | ||||||
| 
 | 
 | ||||||
|     alcMakeContextCurrent(context); // context must be current to get version
 |     alcMakeContextCurrent(context); // context must be current to get version
 | ||||||
| 
 | 
 | ||||||
|     // Version is in format "OpenAL 1.0"
 |      | ||||||
|     ss << alGetString(AL_VERSION); |     ss << alGetString(AL_VERSION); | ||||||
|     ss >> junks >> major >> junkc >> minor; | #if defined(WINVER) | ||||||
|     return util::VersionInfo(major,minor,0); |     ss >> junks >> major >> junkc >> minor;   // format is "OpenAL 1.0"
 | ||||||
|  | #elif defined(linux) | ||||||
|  |     ss >> major >> junkc >> minor >> junkc >> patch; | ||||||
|  | #else | ||||||
|  |     #warning OpenAL only built on Windows/Linux, find out version on OSX | ||||||
|  | #endif | ||||||
|  |      | ||||||
|  |      | ||||||
|  |     //std::cerr << util::VersionInfo(major,minor,patch);
 | ||||||
|  |     return util::VersionInfo(major,minor,patch); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::string AudioCore::checkOpenALError() | std::string AudioCore::checkOpenALError() | ||||||
|  |  | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| //  James Turk (jpt2433@rit.edu)
 | //  James Turk (jpt2433@rit.edu)
 | ||||||
| //
 | //
 | ||||||
| // Version:
 | // Version:
 | ||||||
| //  $Id: ConfigFile.cpp,v 1.5 2005/03/03 09:25:47 cozman Exp $
 | //  $Id: ConfigFile.cpp,v 1.6 2005/05/15 02:50:52 cozman Exp $
 | ||||||
| 
 | 
 | ||||||
| #include "util/ConfigFile.hpp" | #include "util/ConfigFile.hpp" | ||||||
| #include "exceptions.hpp" | #include "exceptions.hpp" | ||||||
|  | @ -58,6 +58,7 @@ void ConfigFile::open(const std::string& filename) | ||||||
|     { |     { | ||||||
|         std::getline(file,str);    //read in a line
 |         std::getline(file,str);    //read in a line
 | ||||||
|         clean = cleanString(str);    //get a clean version
 |         clean = cleanString(str);    //get a clean version
 | ||||||
|  |          | ||||||
| 
 | 
 | ||||||
|         //if std::string is bracketed it is a section
 |         //if std::string is bracketed it is a section
 | ||||||
|         if(clean[0] == '[' && clean[clean.length()-1] == ']') |         if(clean[0] == '[' && clean[clean.length()-1] == ']') | ||||||
|  | @ -141,9 +142,13 @@ void ConfigFile::flush() | ||||||
| void ConfigFile::close() | void ConfigFile::close() | ||||||
| { | { | ||||||
|     //flush and clear out the data members
 |     //flush and clear out the data members
 | ||||||
|     flush(); |     if(!filename_.empty()) | ||||||
|  |     { | ||||||
|  |         flush(); | ||||||
|  |     } | ||||||
|  |      | ||||||
|     filename_ = std::string(); |     filename_ = std::string(); | ||||||
|     layout_.clear(); |         layout_.clear(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| std::string ConfigFile::cleanString(const std::string& str) | std::string ConfigFile::cleanString(const std::string& str) | ||||||
|  | @ -155,12 +160,16 @@ std::string ConfigFile::cleanString(const std::string& str) | ||||||
|                     static_cast<int(*)(int)>(std::tolower) ); |                     static_cast<int(*)(int)>(std::tolower) ); | ||||||
|                      |                      | ||||||
|     //remove all spaces
 |     //remove all spaces
 | ||||||
|     for(std::string::iterator i=ret.begin(); i != ret.end(); ++i) |     for(std::string::iterator i=ret.begin(); i != ret.end(); ) | ||||||
|     { |     { | ||||||
|         if(std::isspace(*i)) |         if(std::isspace(*i)) | ||||||
|         { |         { | ||||||
|             i = ret.erase(i); |             i = ret.erase(i); | ||||||
|         } |         } | ||||||
|  |         else | ||||||
|  |         { | ||||||
|  |             ++i; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return ret; |     return ret; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 James Turk
						James Turk