loadfile_t takes Buffer ref instead of ptr
This commit is contained in:
parent
a46b5baa05
commit
0daac5781e
10
WFObj.cc
10
WFObj.cc
@ -135,7 +135,7 @@ bool WFObj::load(const char *fname)
|
||||
m_path = fname;
|
||||
|
||||
Buffer buff;
|
||||
if (!m_loadfile(fname, &buff))
|
||||
if (!m_loadfile(fname, buff))
|
||||
return false;
|
||||
|
||||
return load(buff);
|
||||
@ -330,7 +330,7 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref)
|
||||
void WFObj::loadMaterial(const std::string & name)
|
||||
{
|
||||
Buffer buff;
|
||||
if (!m_loadfile(name.c_str(), &buff))
|
||||
if (!m_loadfile(name.c_str(), buff))
|
||||
{
|
||||
cerr << "WFObj: error: couldn't open material file '" << name << "'"
|
||||
<< endl;
|
||||
@ -413,7 +413,7 @@ void WFObj::loadMaterial(const std::string & name)
|
||||
}
|
||||
}
|
||||
|
||||
bool WFObj::loadfile(const char *path, Buffer *buff)
|
||||
bool WFObj::loadfile(const char *path, Buffer & buff)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
@ -422,8 +422,8 @@ bool WFObj::loadfile(const char *path, Buffer *buff)
|
||||
int fd = open(path, O_RDONLY);
|
||||
if (fd > 0)
|
||||
{
|
||||
buff->alloc(st.st_size);
|
||||
int num_read = read(fd, buff->data, st.st_size);
|
||||
buff.alloc(st.st_size);
|
||||
int num_read = read(fd, buff.data, st.st_size);
|
||||
close(fd);
|
||||
if (num_read > 0)
|
||||
return true;
|
||||
|
4
WFObj.h
4
WFObj.h
@ -28,7 +28,7 @@ public:
|
||||
bool m_alloc;
|
||||
};
|
||||
|
||||
typedef bool (*loadfile_t)(const char *fname, Buffer *buff);
|
||||
typedef bool (*loadfile_t)(const char *fname, Buffer & buff);
|
||||
typedef GLuint (*loadtexture_t)(const char *fname);
|
||||
|
||||
enum { VERTEX, VERTEX_TEXTURE, VERTEX_NORMAL, VERTEX_TYPES };
|
||||
@ -96,7 +96,7 @@ protected:
|
||||
std::vector<Face> readFaces(const std::vector<std::string> & parts);
|
||||
VertexRef readVertexRef(const std::string ref);
|
||||
void updateAABB();
|
||||
static bool loadfile(const char *path, Buffer *buff);
|
||||
static bool loadfile(const char *path, Buffer & buff);
|
||||
std::string getLine(const Buffer & buff, size_t idx, size_t *update_idx);
|
||||
void loadMaterial(const std::string & name);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user