working on buildVBO()
This commit is contained in:
parent
6dab4e48a6
commit
40c37dacb2
24
WFObj.cc
24
WFObj.cc
@ -440,10 +440,10 @@ bool WFObj::loadfile(const char *path, Buffer & buff)
|
||||
return false;
|
||||
}
|
||||
|
||||
void WFObj::buildVBO()
|
||||
bool WFObj::buildVBO()
|
||||
{
|
||||
map<VertexRef, int> flat_vertices;
|
||||
int vid = 0;
|
||||
int vid = 0, texture_ref_count = 0;
|
||||
glGenBuffers(1, &m_vbo);
|
||||
bool do_textures = m_loadtexture != NULL
|
||||
&& m_vertices[VERTEX_TEXTURE].size() > 0;
|
||||
@ -457,10 +457,28 @@ void WFObj::buildVBO()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
flat_vertices[fit->vertices[i]] = vid++;
|
||||
VertexRef vf = fit->vertices[i];
|
||||
if ( (vf.vertex < 1)
|
||||
|| (vf.texture < 0)
|
||||
|| (vf.normal < 1)
|
||||
|| (vf.vertex > m_vertices[VERTEX].size())
|
||||
|| (vf.normal > m_vertices[VERTEX_NORMAL].size())
|
||||
|| (vf.texture > m_vertices[VERTEX_TEXTURE].size()) )
|
||||
{
|
||||
cerr << "WFObj: error: invalid vertex reference (<"
|
||||
<< vf.vertex << ", " << vf.texture << ", "
|
||||
<< vf.normal << ">)" << endl;
|
||||
return false;
|
||||
}
|
||||
if (vf.texture != 0)
|
||||
texture_ref_count++;
|
||||
flat_vertices[vf] = vid++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (texture_ref_count == 0)
|
||||
do_textures = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool WFObj::VertexRef::operator<(const VertexRef & other) const
|
||||
|
2
WFObj.h
2
WFObj.h
@ -99,7 +99,7 @@ protected:
|
||||
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);
|
||||
void buildVBO();
|
||||
bool buildVBO();
|
||||
|
||||
/* variables */
|
||||
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
||||
|
Loading…
x
Reference in New Issue
Block a user