From 67010e02c20ac4cdb5477cff18803f5523223d6b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sat, 21 May 2011 23:33:28 -0400 Subject: [PATCH] add Engine::loadWFObjFile() --- src/Engine.cc | 21 ++++++++++++++++++++- src/Engine.h | 1 + wfobj | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Engine.cc b/src/Engine.cc index 62209bd..d8b9185 100644 --- a/src/Engine.cc +++ b/src/Engine.cc @@ -101,6 +101,11 @@ static const unsigned char *loadFile(const char *fname, unsigned int *size) return g_engine->loadFile(fname, size); } +static bool loadWFObjFile(const char *fname, WFObj::Buffer & buff) +{ + return g_engine->loadWFObjFile(fname, buff); +} + static GLuint loadTexture(const char *fname) { return g_engine->loadTexture(fname); @@ -605,7 +610,7 @@ int Engine::loadModel(const string & name, bool is_static, bool is_reference, WFObj * obj = new WFObj(); - if (obj->load(model_path.c_str(), &::loadFile, &::loadTexture)) + if (obj->load(model_path.c_str(), &::loadWFObjFile, &::loadTexture)) { int id = addObject(obj, is_static, is_reference, enable_blending, scale); @@ -1299,6 +1304,20 @@ const unsigned char *Engine::loadFile(const char *fname, unsigned int *len) return NULL; } +bool Engine::loadWFObjFile(const char *fname, WFObj::Buffer & buff) +{ + unsigned int size; + unsigned char *data = loadFile(fname, &size); + if (data != NULL) + { + buff.alloc(size); + memcpy(buff.data, data, size); + free(data); + return true; + } + return false; +} + GLuint Engine::loadTexture(const char *fname) { return m_textureCache.load(fname); diff --git a/src/Engine.h b/src/Engine.h index fe148c7..055feec 100644 --- a/src/Engine.h +++ b/src/Engine.h @@ -253,6 +253,7 @@ class Engine bool import(const char * name); bool importFullPath(const char * path); const unsigned char *loadFile(const char *fname, unsigned int *len); + bool loadWFObjFile(const char *fname, WFObj::Buffer & buff); GLuint loadTexture(const char * name); void debug_hook(lua_Debug * debug); void setGravity(float gx, float gy, float gz) diff --git a/wfobj b/wfobj index 1ecc6d7..e6b8c17 160000 --- a/wfobj +++ b/wfobj @@ -1 +1 @@ -Subproject commit 1ecc6d749be3bc3f5dc0de230b5e8e3ca079377a +Subproject commit e6b8c173451603db46f33aa2f55cb899d8bbfc5e