Comment on: Passing a dynamic array into an OpenGL vertex buffer? Any thoughts.
0 16 Sep 2015 05:42 u/1011011101101 in v/programmingComment on: Passing a dynamic array into an OpenGL vertex buffer? Any thoughts.
C++, It's been a while since I was learning but what I had was something like this:
std::int numOfVerts = vertexCount(); // returns the number of vertex floats for the object std::int temp = 0; std::string str = ""; std::string::size_type sz;
fstream infile; infile.open("data_PLY.txt", ios::in);
GLfloat *vertices;
vertices = new float[numOfVerts];
while( int i = 0; i < numOfVerts; i++) { infile >> str; temp = stof(infile, &sz); vertices[i] = temp; temp = 0; }
It was something along those lines. I apologize, I'm not very good at coding but I love it none the less but when I passed it into the vertex buffer it never worked because it wanted a static array.
number of floats/vertex points, I'm usually calling glDrawElements() with a separate GLuint array for the order of the triangles.