add initial buildVBO()
This commit is contained in:
parent
66d4bb50e4
commit
67ef0c4009
17
WFObj.cc
17
WFObj.cc
@ -1,4 +1,6 @@
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
@ -7,12 +9,15 @@
|
||||
#include <string.h> /* strlen() */
|
||||
#include <stdlib.h> /* atoi */
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include "WFObj.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define WHITESPACE " \n\r\t\v"
|
||||
@ -103,6 +108,8 @@ WFObj::WFObj(loadfile_t lf, loadtexture_t lt)
|
||||
{
|
||||
m_loadfile = loadfile;
|
||||
}
|
||||
if (m_valid)
|
||||
glDeleteBuffers(1, &m_vbo);
|
||||
m_valid = false;
|
||||
clear();
|
||||
}
|
||||
@ -160,6 +167,9 @@ bool WFObj::load(const WFObj::Buffer &buff)
|
||||
}
|
||||
|
||||
updateAABB();
|
||||
|
||||
buildVBO();
|
||||
m_valid = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -430,6 +440,13 @@ bool WFObj::loadfile(const char *path, Buffer & buff)
|
||||
return false;
|
||||
}
|
||||
|
||||
void WFObj::buildVBO()
|
||||
{
|
||||
glGenBuffers(1, &m_vbo);
|
||||
bool do_textures = m_loadtexture != NULL
|
||||
&& m_vertices[VERTEX_TEXTURE].size() > 0;
|
||||
}
|
||||
|
||||
bool WFObj::VertexRef::operator<(const VertexRef & other)
|
||||
{
|
||||
if (vertex != other.vertex)
|
||||
|
2
WFObj.h
2
WFObj.h
@ -99,6 +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();
|
||||
|
||||
/* variables */
|
||||
std::vector<Vertex> m_vertices[VERTEX_TYPES];
|
||||
@ -110,6 +111,7 @@ protected:
|
||||
loadtexture_t m_loadtexture;
|
||||
std::string m_current_material_name;
|
||||
bool m_valid;
|
||||
GLuint m_vbo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user