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