Compare commits
4
Commits
1918cc89bf
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4dc0f4d36 | ||
|
|
e6b8c17345 | ||
|
|
1ecc6d749b | ||
|
|
08e558482f |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
# vim:filetype=python
|
||||
|
||||
env = Environment(LIBS = ['GL'], CXXFLAGS = ['-Wall'])
|
||||
env = Environment(LIBS = ['GL'], CXXFLAGS = ['-Wall', '-DGL_GLEXT_PROTOTYPES'])
|
||||
|
||||
env.Program('driver', Glob('*.cc'))
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@@ -341,7 +339,7 @@ WFObj::VertexRef WFObj::readVertexRef(const std::string ref)
|
||||
void WFObj::loadMaterial(const std::string & name)
|
||||
{
|
||||
Buffer buff;
|
||||
string path = (name[0] != '/') ? basePath(m_path) + name : name;
|
||||
string path = resolvePath(name);
|
||||
if (!m_loadfile(path.c_str(), buff))
|
||||
{
|
||||
cerr << "WFObj: error: couldn't open material file '" << path << "'"
|
||||
@@ -422,7 +420,7 @@ void WFObj::loadMaterial(const std::string & name)
|
||||
}
|
||||
else if (tokens[0] == "map_Kd")
|
||||
{
|
||||
m_materials[mat_name].texture = loadTexture(tokens[1]);
|
||||
m_materials[mat_name].texture = loadTexture(resolvePath(tokens[1]));
|
||||
if (m_materials[mat_name].texture != 0)
|
||||
m_materials[mat_name].flags |= Material::TEXTURE_BIT;
|
||||
}
|
||||
@@ -464,6 +462,12 @@ bool WFObj::buildVBO()
|
||||
it != m_faces.end();
|
||||
it++)
|
||||
{
|
||||
if (m_materials.find(it->first) == m_materials.end())
|
||||
{
|
||||
cerr << "Material '" << it->first << "' referenced in '"
|
||||
<< m_path << "' is not defined." << endl;
|
||||
return false;
|
||||
}
|
||||
for (vector<Face>::iterator fit = it->second.begin();
|
||||
fit != it->second.end();
|
||||
fit++)
|
||||
@@ -571,6 +575,11 @@ GLuint WFObj::loadTexture(const std::string & path)
|
||||
return id;
|
||||
}
|
||||
|
||||
string WFObj::resolvePath(const string & name)
|
||||
{
|
||||
return (name[0] != '/') ? basePath(m_path) + name : name;
|
||||
}
|
||||
|
||||
bool WFObj::VertexRef::operator<(const VertexRef & other) const
|
||||
{
|
||||
if (vertex != other.vertex)
|
||||
|
||||
@@ -19,7 +19,7 @@ public:
|
||||
class Buffer
|
||||
{
|
||||
public:
|
||||
Buffer() : m_alloc(false) {}
|
||||
Buffer() : m_alloc(false) {data = NULL; length = 0;}
|
||||
~Buffer() { if (m_alloc) delete data; }
|
||||
uint8_t *data;
|
||||
size_t length;
|
||||
@@ -116,6 +116,7 @@ protected:
|
||||
void loadMaterial(const std::string & name);
|
||||
bool buildVBO();
|
||||
GLuint loadTexture(const std::string & path);
|
||||
std::string resolvePath(const std::string & name);
|
||||
|
||||
/* variables */
|
||||
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
||||
|
||||
Reference in new issue
Block a user