update WFObj construction, loadFile()/loadTexture()

This commit is contained in:
Josh Holtrop 2011-05-19 23:14:10 -04:00
parent f1bc763be2
commit f78c42c8c8
2 changed files with 21 additions and 14 deletions

View File

@ -96,6 +96,16 @@ static vector<string> 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 ********/

View File

@ -9,7 +9,7 @@
#include <SDL.h>
#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;