Here the code for loading data from a txt file to a normal array. What i'm trying to do now, is to load that data to a GLfloat vertice[].
#include <iostream>#include <fstream>using namespace std;float vertices[2999];void CreateDataFile(){ ofstream out("testfile.txt"); for (float x=0;x<10;x++) for (float y=0;y<10;y++) for (float z=0;z<10;z++) { if ((x == 9) && (y == 9) && (z == 9)) { out << x*0.123456 << " " << y*0.123456 << " " << z*0.123456; } else out << x*0.123456 << " " << y*0.123456 << " " << z*0.123456 << "\n"; }}int main(){ CreateDataFile(); ifstream loadData("testfile.txt"); if (!loadData) { cout<< "Can't open file!\n"; return 1; } else { int j = 0; cout.precision(2); while (loadData >> vertices[j]) { //cout << vertices[j] << ","; ++j; } //cout << j; cout << vertices[1]; } loadData.close(); return 0;}
I tried it for a GLfloat vertices array, but it didnt work. Could someone help find the best way to upload data in a GLfloat vertice[]?
Thanks