From 67ef0c4009df10cd48e9e1d5777ee2a0084e7e9e Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 20 Apr 2011 16:29:59 -0400 Subject: [PATCH] add initial buildVBO() --- WFObj.cc | 17 +++++++++++++++++ WFObj.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/WFObj.cc b/WFObj.cc index 5a93164..88a8f10 100644 --- a/WFObj.cc +++ b/WFObj.cc @@ -1,4 +1,6 @@ +#define GL_GLEXT_PROTOTYPES + #include #include #include @@ -7,12 +9,15 @@ #include /* strlen() */ #include /* atoi */ #include + #include #include #include #include #include + #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) diff --git a/WFObj.h b/WFObj.h index 8cf2830..51568fa 100644 --- a/WFObj.h +++ b/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 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