From e328885f766b694d66b2baef4e2360a33492de59 Mon Sep 17 00:00:00 2001 From: James Turk Date: Mon, 8 Aug 2005 21:39:40 +0000 Subject: [PATCH] Windows build changes / OpenAL fixes --- SConstruct | 7 ++- include/Application.hpp | 11 +++- include/audio/Source.hpp | 14 +++-- include/photon.hpp | 79 ++++++++++++++------------- include/video/FontResourceManager.hpp | 4 +- src/Application.cpp | 6 +- src/audio/AudioCore.cpp | 8 +-- test/Audio_test.cpp | 4 +- test/config1.ini | 22 ++++---- test/config2.ini | 18 +++--- 10 files changed, 93 insertions(+), 80 deletions(-) diff --git a/SConstruct b/SConstruct index c58da00..0760d98 100644 --- a/SConstruct +++ b/SConstruct @@ -5,7 +5,7 @@ # James Turk (jpt2433@rit.edu) # # Version: -# $Id: SConstruct,v 1.18 2005/07/18 05:14:18 cozman Exp $ +# $Id: SConstruct,v 1.19 2005/08/08 21:39:40 cozman Exp $ import os,os.path import glob @@ -16,6 +16,7 @@ def getFilesMulti(paths, pat): filelist = [] for d in paths: filelist += glob.glob( os.path.join(d,pat) ) + filelist = [ f.replace(os.path.sep,'/') for f in filelist] return filelist ## config variables ## @@ -26,7 +27,7 @@ INC_DIRS = ["include/%s" % d for d in SUB_DIRS] SRC_FILES = [f.replace('src','build') for f in getFilesMulti(SRC_DIRS, '*.cpp')] INC_FILES = getFilesMulti(INC_DIRS, '*.hpp') -libsMap = { 'nt':('opengl32','glu32','openal32'), +libsMap = { 'nt':('opengl32','glu32',['openal32','alut']), 'posix':('GL','GLU','openal'), 'mac':('GL','GLU','openal')} try: @@ -52,7 +53,7 @@ def BuildSuperHeader(target = None, source = None, env = None): SuperHeaderAction = Action(BuildSuperHeader) # Configure the environment (Check libraries): -env = Environment() +env = Environment(ENV = os.environ) env.Append(CPPPATH='include', CPPFLAGS='-Wall') env.ParseConfig('freetype-config --cflags') # Configure diff --git a/include/Application.hpp b/include/Application.hpp index 96a00e1..9365dfb 100644 --- a/include/Application.hpp +++ b/include/Application.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Application.hpp,v 1.15 2005/08/08 19:19:24 cozman Exp $ +// $Id: Application.hpp,v 1.16 2005/08/08 21:39:41 cozman Exp $ #ifndef PHOTON_APPLICATION_HPP #define PHOTON_APPLICATION_HPP @@ -305,6 +305,7 @@ public: template void setCurrentState(); +#ifdef PHOTON_USE_OPENAL // Group: AudioCore public: // Function: getAudioCore @@ -320,8 +321,10 @@ public: // it via . // // Arguments: - // deviceName - Name for desired Audio device. - void initAudioCore(const std::string& deviceName); + // deviceName - Optional name for desired Audio device, will use default + // device if none specified. + void initAudioCore(const std::string& deviceName=""); +#endif //PHOTON_USE_OPENAL // API Initialization private: @@ -414,7 +417,9 @@ private: static std::vector pressedKeys_; // Cores + #ifdef PHOTON_USE_OPENAL std::auto_ptr audioCore_; + #endif //PHOTON_USE_OPENAL }; template diff --git a/include/audio/Source.hpp b/include/audio/Source.hpp index 3492108..9d0e41c 100644 --- a/include/audio/Source.hpp +++ b/include/audio/Source.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Source.hpp,v 1.3 2005/07/18 05:14:18 cozman Exp $ +// $Id: Source.hpp,v 1.4 2005/08/08 21:39:41 cozman Exp $ #ifdef PHOTON_USE_OPENAL @@ -202,7 +202,8 @@ void Source::open(const std::string& name) uint bufferID; ResourceManaged::open(name); - resMgr_.getAudioData(getName(), bufferID); + ResourceManaged::resMgr_.getAudioData( + ResourceManaged::getName(), bufferID); // attach buffer to source alSourcei(sourceID_, AL_BUFFER, bufferID); @@ -222,7 +223,8 @@ Source& Source::operator=(const Source& rhs) uint bufferID; ResourceManaged::operator=(rhs); - resMgr_.getAudioData(getName(), bufferID); + ResourceManaged::resMgr_.getAudioData( + ResourceManaged::getName(), bufferID); // attach buffer to source alSourcei(sourceID_, AL_BUFFER, bufferID); @@ -335,13 +337,15 @@ template void Source::addResource(const std::string& name, const std::string& path) { - resMgr_.newResource(name, ResourceDescriptor(path)); + ResourceManaged::resMgr_.newResource(name, + ResourceDescriptor(path)); } template void Source::addResource(const std::string& path) { - resMgr_.newResource(path, ResourceDescriptor(path)); + ResourceManaged::resMgr_.newResource(path, + ResourceDescriptor(path)); } } diff --git a/include/photon.hpp b/include/photon.hpp index 9b3eeb7..9bcf75d 100644 --- a/include/photon.hpp +++ b/include/photon.hpp @@ -1,39 +1,40 @@ -#ifndef PHOTON_HPP -#define PHOTON_HPP - -#include "Kernel.hpp" -#include "types.hpp" -#include "State.hpp" -#include "Application.hpp" -#include "Task.hpp" -#include "exceptions.hpp" -#include "photon.hpp" -#include "InputListener.hpp" -#include "entrypoint.hpp" -#include "LogSink.hpp" -#include "Log.hpp" -#include "ResourceManaged.hpp" -#include "ResourceManager.hpp" -#include "audio/SampleResourceManager.hpp" -#include "audio/Source.hpp" -#include "audio/AudioCore.hpp" -#include "math/math.hpp" -#include "math/Rect.hpp" -#include "math/Vector2.hpp" -#include "math/Circle.hpp" -#include "util/ConfigFile.hpp" -#include "util/VersionInfo.hpp" -#include "util/Singleton.hpp" -#include "util/RandGen.hpp" -#include "util/Timer.hpp" -#include "util/FileBuffer.hpp" -#include "util/filesys/filesys.hpp" -#include "video/Pen.hpp" -#include "video/Image.hpp" -#include "video/FontResourceManager.hpp" -#include "video/Texture.hpp" -#include "video/Color.hpp" -#include "video/TextureResourceManager.hpp" -#include "video/Font.hpp" - -#endif // PHOTON_HPP +#ifndef PHOTON_HPP +#define PHOTON_HPP + +#include "Application.hpp" +#include "entrypoint.hpp" +#include "exceptions.hpp" +#include "InputListener.hpp" +#include "Kernel.hpp" +#include "Log.hpp" +#include "LogSink.hpp" +#include "photon.hpp" +#include "ResourceManaged.hpp" +#include "ResourceManager.hpp" +#include "State.hpp" +#include "Task.hpp" +#include "types.hpp" +#include "audio/AudioCore.hpp" +#include "audio/SampleResourceManager.hpp" +#include "audio/Source.hpp" +#include "math/Circle.hpp" +#include "math/math.hpp" +#include "math/Rect.hpp" +#include "math/Vector2.hpp" +#include "util/ConfigFile.hpp" +#include "util/FileBuffer.hpp" +#include "util/RandGen.hpp" +#include "util/Singleton.hpp" +#include "util/Timer.hpp" +#include "util/VersionInfo.hpp" +#include "util/filesys/filesys.hpp" +#include "video/Color.hpp" +#include "video/Font.hpp" +#include "video/FontResourceManager.hpp" +#include "video/Image.hpp" +#include "video/Pen.hpp" +#include "video/Texture.hpp" +#include "video/TextureResourceManager.hpp" +#include "video/VideoCore.hpp" + +#endif // PHOTON_HPP diff --git a/include/video/FontResourceManager.hpp b/include/video/FontResourceManager.hpp index 3357422..b5caf12 100644 --- a/include/video/FontResourceManager.hpp +++ b/include/video/FontResourceManager.hpp @@ -5,14 +5,14 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: FontResourceManager.hpp,v 1.4 2005/07/18 07:19:48 cozman Exp $ +// $Id: FontResourceManager.hpp,v 1.5 2005/08/08 21:39:41 cozman Exp $ #ifndef PHOTON_VIDEO_FONTRESOURCEMANAGER_HPP #define PHOTON_VIDEO_FONTRESOURCEMANAGER_HPP #include "ResourceManager.hpp" -#include +#include "ft2build.h" #include FT_FREETYPE_H namespace photon diff --git a/src/Application.cpp b/src/Application.cpp index 1ec0ce2..bd11f01 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Application.cpp,v 1.19 2005/08/08 19:19:21 cozman Exp $ +// $Id: Application.cpp,v 1.20 2005/08/08 21:39:41 cozman Exp $ #include "Application.hpp" @@ -386,6 +386,8 @@ double Application::getFramerate() { return 1/updateTask_->secPerFrame_; } +// AudioCore /////////////////////////////////////////////////////////////////// +#ifdef PHOTON_USE_OPENAL audio::AudioCore& Application::getAudioCore() { @@ -411,6 +413,8 @@ void Application::initAudioCore(const std::string& deviceName) } } +#endif //PHOTON_USE_OPENAL + // API initialization ////////////////////////////////////////////////////////// util::VersionInfo Application::initPhysFS(const std::string& arg0) diff --git a/src/audio/AudioCore.cpp b/src/audio/AudioCore.cpp index 51f5eae..d1b470e 100644 --- a/src/audio/AudioCore.cpp +++ b/src/audio/AudioCore.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: AudioCore.cpp,v 1.12 2005/08/08 07:00:46 cozman Exp $ +// $Id: AudioCore.cpp,v 1.13 2005/08/08 21:39:41 cozman Exp $ #ifdef PHOTON_USE_OPENAL @@ -133,12 +133,10 @@ util::VersionInfo AudioCore::initOpenAL(const std::string& deviceName) // OpenAL needs a standard version string format badly ss << alGetString(AL_VERSION); -#if defined(WINVER) - ss >> junks >> major >> junkc >> minor; // format is "OpenAL 1.0" -#elif defined(linux) +#if defined(linux) ss >> major >> junkc >> minor >> junkc >> patch; #else - #warning OpenAL only built on Windows/Linux, find out version on OSX + ss >> junks >> major >> junkc >> minor; // format is "OpenAL 1.0" #endif throwOpenALError("AudioCore::initOpenAL"); diff --git a/test/Audio_test.cpp b/test/Audio_test.cpp index 854fe42..f4f9dc3 100644 --- a/test/Audio_test.cpp +++ b/test/Audio_test.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: Audio_test.cpp,v 1.11 2005/08/08 19:24:30 cozman Exp $ +// $Id: Audio_test.cpp,v 1.12 2005/08/08 21:39:41 cozman Exp $ #include "photon.hpp" using namespace photon; @@ -187,7 +187,7 @@ int PhotonMain(const StrVec& args) // create window Application::getInstance().createDisplay(800,600,32,0,0,false); // initialize audio core - Application::getInstance().initAudioCore("OSS"); + Application::getInstance().initAudioCore(); // be sure to add FPSDisplayTask Kernel::getInstance().addTask(TaskPtr(new FPSDisplayTask())); diff --git a/test/config1.ini b/test/config1.ini index 919ca2e..909cde7 100644 --- a/test/config1.ini +++ b/test/config1.ini @@ -1,11 +1,11 @@ -[] -#config1.ini - -[sec2] - fancy = 0 - fancy2 = "james" - -[sec] -int=3 -float=3 -string=three +[] +#config1.ini + +[sec2] + fancy = 0 + fancy2 = "james" + +[sec] +int=3 +float=3 +string=three diff --git a/test/config2.ini b/test/config2.ini index 37af61e..e47b545 100644 --- a/test/config2.ini +++ b/test/config2.ini @@ -1,9 +1,9 @@ -[] -#config2.ini - -[sec] -var = 0 - hex = 0xff - -[sec2] - var = 2 +[] +#config2.ini + +[sec] +var = 0 + hex = 0xff + +[sec2] + var = 2