37 lines
846 B
C++
37 lines
846 B
C++
|
|
#include <GL/gl.h>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
class WFObj
|
|
{
|
|
public:
|
|
bool load(const std::string & filename);
|
|
GLuint render();
|
|
|
|
private:
|
|
/* types */
|
|
class Vertex
|
|
{
|
|
public:
|
|
float operator[](int idx) const { return data[idx]; }
|
|
const float & operator[](int idx) { return data[idx]; }
|
|
float * getData() { return data; }
|
|
private:
|
|
float data[4];
|
|
};
|
|
|
|
/* methods */
|
|
void clear();
|
|
std::string trim(std::string s);
|
|
int filesize(const char * filename);
|
|
void processInputLine(const std::string & input);
|
|
std::string stripFirstToken(std::string & input);
|
|
Vertex readVertex(const std::vector<std::string> & parts);
|
|
void parseVertexIndices(const std::string & vtxref, int * ret);
|
|
std::vector<std::string> splitString(const std::string & str, char delim);
|
|
|
|
/* variables */
|
|
std::vector< std::vector<std::string> > m_data;
|
|
};
|