From 7451b89ef4eeee7f7dcf7823e62eb5f6664ab5d6 Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 10 Jun 2005 07:06:06 +0000 Subject: [PATCH] code with Texture compiles (untested) --- SConstruct | 8 ++++++-- include/ResourceManaged.hpp | 6 +++--- include/ResourceManager.hpp | 10 +++++----- include/photon.hpp | 2 ++ include/util/FileBuffer.hpp | 8 ++++---- photon.mm | 8 ++++++-- src/util/FileBuffer.cpp | 8 +++++++- test/exception_test.cpp | 5 ++++- 8 files changed, 37 insertions(+), 18 deletions(-) diff --git a/SConstruct b/SConstruct index e62367b..6e31c3d 100644 --- a/SConstruct +++ b/SConstruct @@ -5,7 +5,7 @@ # James Turk (jpt2433@rit.edu) # # Version: -# $Id: SConstruct,v 1.10 2005/05/15 02:51:51 cozman Exp $ +# $Id: SConstruct,v 1.11 2005/06/10 07:06:06 cozman Exp $ import os,os.path import glob @@ -29,7 +29,7 @@ INC_FILES = getFilesMulti(INC_DIRS, '*.hpp') libsMap = { 'nt':('opengl32','glu32','openal32'), 'posix':('GL','GLU','openal'), - 'mac':('GL','GLU','openal') } + 'mac':('GL','GLU','openal')} try: OGL_LIB,GLU_LIB,OAL_LIB = libsMap[os.name] except KeyError: @@ -55,6 +55,9 @@ if not conf.CheckLibWithHeader(GLU_LIB, 'GL/glu.h', 'C++'): if not conf.CheckLibWithHeader('glfw', 'GL/glfw.h', 'C++'): print 'GLFW not found, exiting.' Exit(1) +if not conf.CheckLibWithHeader('corona', 'corona.h', 'C++'): + print 'Corona not found, exiting.' + Exit(1) env = conf.Finish() # Build the Super-Header @@ -65,6 +68,7 @@ header.write('#define '+incGuard+'\n\n') for inc in INC_FILES: header.write('#include "'+inc.replace('include/','')+'"\n') header.write('\n#endif // '+incGuard+'\n') +header.close() # Define Builds: BuildDir('build', 'src', duplicate=0) diff --git a/include/ResourceManaged.hpp b/include/ResourceManaged.hpp index caad403..a7d0f20 100644 --- a/include/ResourceManaged.hpp +++ b/include/ResourceManaged.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: ResourceManaged.hpp,v 1.2 2005/06/10 05:48:59 cozman Exp $ +// $Id: ResourceManaged.hpp,v 1.3 2005/06/10 07:06:06 cozman Exp $ #ifndef PHOTON_RESOURCEMANAGED_HPP #define PHOTON_RESOURCEMANAGED_HPP @@ -70,7 +70,7 @@ public: // Function: cleanUp // Cleans up any unused resources of the type. // (Ex. Image::cleanUp() will unload all images.) - static virtual void cleanUp(); + virtual void cleanUp(); // Function: addResource // Define a new named resource. @@ -92,7 +92,7 @@ public: // path - Path of resource data file. static void addResource(const std::string& path); -private: +protected: static ResMgrT resMgr_; uint resID_; }; diff --git a/include/ResourceManager.hpp b/include/ResourceManager.hpp index 4cbd2de..58a59c2 100644 --- a/include/ResourceManager.hpp +++ b/include/ResourceManager.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: ResourceManager.hpp,v 1.2 2005/06/10 05:48:59 cozman Exp $ +// $Id: ResourceManager.hpp,v 1.3 2005/06/10 07:06:06 cozman Exp $ #ifndef PHOTON_RESOURCEMANAGER_HPP #define PHOTON_RESOURCEMANAGER_HPP @@ -54,13 +54,13 @@ public: void cleanUp(); private: - virtual void loadResource(resT &res, const std::string& name)=0; + virtual void loadResource(resT &res, const std::string& path)=0; virtual void freeResource(resT &res)=0; uint newResource(const std::string& name, const std::string& path); void deleteResource(uint id); -private: +protected: std::vector resVec_; }; @@ -101,7 +101,7 @@ template void ResourceManager::delRef(uint id) { // if decremented count is <= 0, delete resource - if(id < resVec_.size() && --resVec_[id].refcount <= 0) + if(id < resVec_.size() && --resVec_[id].refCount <= 0) { deleteResource(id); } @@ -130,7 +130,7 @@ uint ResourceManager::newResource(const std::string& name, try { // attempt to load - loadResource(res, name, path); + loadResource(res, path); } catch(ResourceException&) { diff --git a/include/photon.hpp b/include/photon.hpp index 43b167a..f22e933 100644 --- a/include/photon.hpp +++ b/include/photon.hpp @@ -26,7 +26,9 @@ #include "util/FileBuffer.hpp" #include "util/filesys/filesys.hpp" #include "video/Pen.hpp" +#include "video/Texture.hpp" #include "video/Color.hpp" +#include "video/TextureResourceManager.hpp" #include "video/VideoCore.hpp" #endif // PHOTON_HPP diff --git a/include/util/FileBuffer.hpp b/include/util/FileBuffer.hpp index 13c7548..7bec2ff 100644 --- a/include/util/FileBuffer.hpp +++ b/include/util/FileBuffer.hpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: FileBuffer.hpp,v 1.3 2005/03/03 09:25:20 cozman Exp $ +// $Id: FileBuffer.hpp,v 1.4 2005/06/10 07:06:06 cozman Exp $ #ifndef PHOTON_UTIL_FILEBUFFER_HPP #define PHOTON_UTIL_FILEBUFFER_HPP @@ -64,14 +64,14 @@ public: // Function: getData // Loads an amount of data, returns a pointer to the loaded data. // If the requested amount of data wasn't available, returns only - // what could be loaded. + // what could be loaded. If amount is 0 (default), returns entire buffer. // // Parameters: - // amount - maximum amount of data to load + // amount - maximum amount of data to load [default: 0] // // Returns: // Vector containing loaded data, empty if nothing loaded. - std::vector getData(int amount); + std::vector getData(int amount=0); // Function: getPosition // Gets position of internal cursor inside data. diff --git a/photon.mm b/photon.mm index 8abc86f..ab1c5d1 100644 --- a/photon.mm +++ b/photon.mm @@ -4,7 +4,7 @@ - + @@ -40,7 +40,7 @@ - + @@ -78,5 +78,9 @@ + + + + diff --git a/src/util/FileBuffer.cpp b/src/util/FileBuffer.cpp index dece738..5684642 100644 --- a/src/util/FileBuffer.cpp +++ b/src/util/FileBuffer.cpp @@ -5,7 +5,7 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: FileBuffer.cpp,v 1.4 2005/02/16 06:58:26 cozman Exp $ +// $Id: FileBuffer.cpp,v 1.5 2005/06/10 07:06:06 cozman Exp $ #include "util/FileBuffer.hpp" @@ -50,6 +50,12 @@ std::vector FileBuffer::getData(int amount) throw PreconditionException("No file open in FileBuffer::getData"); } + // if amount is 0, read entire buffer + if(amount == 0) + { + amount = getSize(); + } + std::vector buffer(amount); //create buffer // try to read 'amount' bytes into buffer diff --git a/test/exception_test.cpp b/test/exception_test.cpp index 1fdf0c9..a7be3ce 100644 --- a/test/exception_test.cpp +++ b/test/exception_test.cpp @@ -5,9 +5,12 @@ // James Turk (jpt2433@rit.edu) // // Version: -// $Id: exception_test.cpp,v 1.1 2005/05/15 02:50:07 cozman Exp $ +// $Id: exception_test.cpp,v 1.2 2005/06/10 07:06:07 cozman Exp $ #include "photon.hpp" +#include "exceptions.hpp" +#include "entrypoint.hpp" + using namespace photon;