From f78c42c8c8dd9369652eb3bac65e1efb5b8988db Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 19 May 2011 23:14:10 -0400 Subject: [PATCH] update WFObj construction, loadFile()/loadTexture() --- src/Engine.cc | 29 ++++++++++++++++++----------- src/Engine.h | 6 +++--- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/Engine.cc b/src/Engine.cc index 79bf433..a829727 100644 --- a/src/Engine.cc +++ b/src/Engine.cc @@ -96,6 +96,16 @@ static vector split(const string & str, char delim) return ret; } +static const unsigned char *loadFile(const char *fname, unsigned int *size) +{ + return g_engine->loadFile(fname, size); +} + +static GLuint loadTexture(const char *fname) +{ + return g_engine->loadTexture(fname); +} + /******** Engine functions ********/ @@ -116,7 +126,6 @@ Engine::Engine(const string & path, AV & av) m_autoStartFrame = true; m_autoEndFrame = true; m_autoDrawObjects = true; - m_fileLoader = new EngineFileLoader(this); m_event_time = 0; m_font = NULL; m_engine_cursor_visible = m_av.getCursorVisible(); @@ -592,12 +601,12 @@ int Engine::loadModel(const string & name, bool is_static, bool is_reference, string path = name; if (validatePath(path)) { - FileLoader::Path model_path("", path + ".obj"); - FileLoader::Path phys_path("", path + ".phy"); + string model_path = path + ".obj"; + string phys_path = path + ".phy"; - WFObj * obj = new WFObj(*m_fileLoader, m_textureCache); + WFObj * obj = new WFObj(); - if (obj->load(model_path)) + if (obj->load(model_path, &::loadFile, &::loadTexture)) { int id = addObject(obj, is_static, is_reference, enable_blending, scale); @@ -682,12 +691,6 @@ bool Engine::importFullPath(const char * path) return false; } -GLuint Engine::loadTexture(const char * name) -{ - FileLoader::Path path("", name); - return m_textureCache.load(path, *m_fileLoader); -} - GLuint Engine::startList() { GLuint list = glGenLists(1); @@ -1295,6 +1298,10 @@ const unsigned char *Engine::loadFile(const char *fname, unsigned int *len) return NULL; } +GLuint Engine::loadTexture(const char *fname) +{ + return m_textureCache.load(fname); +} /******** Engine::PickedObject functions ********/ diff --git a/src/Engine.h b/src/Engine.h index e48a068..ed13ec4 100644 --- a/src/Engine.h +++ b/src/Engine.h @@ -9,7 +9,7 @@ #include #include "OdeWorld/OdeWorld.h" #include "TextureCache/TextureCache.h" -#include "WFObj/WFObj.h" +#include "wfobj/WFObj.h" #include "AV.h" #include "refptr/refptr.h" #include "ftgl.h" @@ -252,6 +252,7 @@ class Engine void exit(); bool import(const char * name); bool importFullPath(const char * path); + const unsigned char *loadFile(const char *fname, unsigned int *len); GLuint loadTexture(const char * name); void debug_hook(lua_Debug * debug); void setGravity(float gx, float gy, float gz) @@ -300,8 +301,6 @@ class Engine protected: static Uint32 updateCallback(Uint32 interval, void * param); - int getFileSize(const char *fname); - const unsigned char *loadFile(const char *fname, unsigned int *len); Uint32 updateCallback(Uint32 interval); void registerLibraries(); @@ -325,6 +324,7 @@ class Engine m_engine_cursor_visible || m_script_cursor_visible); } bool validatePath(std::string & path); + int getFileSize(const char *fname); AV & m_av; bool m_engine_cursor_visible;