1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
static void drawContent()
{
ifstream file;
file.open("D:/Users/askjmk/Documents/Visual Studio 2013/monkey.obj");
if (file)
{
string ligne;
int lines = 0;
vector<float> fxyz;
while (!file.eof())
{
getline(file, ligne);
string ifv = ligne.substr(0,2);
if (ifv == "v ")
{
string sx = ligne.substr(2, 9);
string sy = ligne.substr(11, 9);
string sz = ligne.substr(21, 9);
float fx = stof(sx);
float fy = stof(sy);
float fz = stof(sz);
fxyz.push_back(fx);
fxyz.push_back(fy);
fxyz.push_back(fz);
lines++;
}
}
if (file.eof())
{
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_DEPTH);
glVertexPointer(3, GL_FLOAT, 0, fxyz.data());
glDrawArrays(GL_QUADS, 0, lines);
glDisable(GL_DEPTH);
glDisableClientState(GL_VERTEX_ARRAY);
}
}
else
{
window.close();
}
} |
Partager