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