fix compilation errors; compiling!

This commit is contained in:
Josh Holtrop 2011-04-19 17:05:17 -04:00
parent 18c4be6a42
commit 51c0ded005
2 changed files with 29 additions and 13 deletions

View File

@ -3,8 +3,9 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <ctype.h> // isspace()
#include <string.h> // strlen()
#include <ctype.h> /* isspace() */
#include <string.h> /* strlen() */
#include <stdlib.h> /* atoi */
#include <GL/gl.h>
#include <vector>
#include <string>
@ -125,9 +126,9 @@ bool WFObj::load(const WFObj::Buffer &buff)
{
string buildup;
size_t idx = 0;
while (idx < buff.size)
while (idx < buff.length)
{
string line = getLine(buff, idx, &idx)
string line = getLine(buff, idx, &idx);
string input = trimString(line);
int sz = input.size();
if (sz == 0 || input[0] == '#')
@ -148,7 +149,7 @@ bool WFObj::load(const WFObj::Buffer &buff)
return true;
}
string WFObj::getLine(const Buff & buff, size_t idx, size_t *update_idx)
string WFObj::getLine(const Buffer & buff, size_t idx, size_t *update_idx)
{
size_t len = 0;
while (idx + len < buff.length)
@ -198,7 +199,9 @@ void WFObj::processInputLine(const std::string & input)
{
if (m_faces.find(m_current_material_name) == m_faces.end())
m_faces[m_current_material_name] = vector<Face>();
m_faces[m_current_material_name].push_back(readFace(tokens));
vector<Face> faces = readFaces(tokens);
for (vector<Face>::iterator it = faces.begin(); it != faces.end(); it++)
m_faces[m_current_material_name].push_back(*it);
}
else if (type == "usemtl")
{
@ -226,6 +229,7 @@ void WFObj::processInputLine(const std::string & input)
void WFObj::updateAABB(const float * const vertex)
{
#ifdef TODO
if (m_loadedVertex)
{
if (vertex[0] < m_aabb[0])
@ -248,6 +252,7 @@ void WFObj::updateAABB(const float * const vertex)
m_aabb[2] = m_aabb[5] = vertex[2];
m_loadedVertex = true;
}
#endif
}
WFObj::Vertex WFObj::readVertex(const vector<string> & parts)
@ -308,3 +313,13 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref)
}
return fr;
}
void WFObj::loadMaterial(const std::string & name)
{
/* TODO */
}
bool WFObj::loadfile(const char *path, Buffer *buff)
{
/* TODO */
}

15
WFObj.h
View File

@ -11,9 +11,6 @@ class WFObj
{
public:
/* types */
typedef bool (*loadfile_t)(const char *fname, Buffer *buff);
typedef GLuint (*loadtexture_t)(const char *fname);
class Buffer
{
public:
@ -21,6 +18,9 @@ public:
size_t length;
};
typedef bool (*loadfile_t)(const char *fname, Buffer *buff);
typedef GLuint (*loadtexture_t)(const char *fname);
enum { VERTEX, VERTEX_TEXTURE, VERTEX_NORMAL, VERTEX_TYPES };
/* constructors */
@ -66,14 +66,15 @@ protected:
std::vector<Face> readFaces(const std::vector<std::string> & parts);
VertexRef readVertexRef(const std::string ref);
void updateAABB(const float * const vertex);
static Buffer loadfile(const char *path);
std::string getLine(const Buff & buff, size_t idx, size_t *update_idx);
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);
/* variables */
std::vector<Vector> m_vertices[VERTEX_TYPES];
std::vector<Vertex> m_vertices[VERTEX_TYPES];
std::map< std::string, std::vector< Face > > m_faces;
FileLoader::Path m_path;
float m_aabb[6];
std::string m_path;
loadfile_t m_loadfile;
loadtexture_t m_loadtexture;
std::string m_current_material_name;