I'm trying to make my code work with pointers, but can't find what is wrong. The first one is working correctly, with global variable declared with the size of the array. The second one are pointers, and can't find what is wrong, because i get no errors, the drawing is just not done.
Code://global #define sizeVertices = 6291456; GLfloat g_vertices[sizeVertices]; GLfloat g_colors[sizeVertices]; bool Init() { ... ifstream loadData("blob3.txt");; if (!loadData) {...} else { while(getline(loadData, t, '\n')) { ++lineCount; } loadData.clear(); loadData.seekg(0, ios::beg); while (j<(lineCount*4)) { for(i=0; i<3;i++) { loadData >> g_vertices[m]; m++; } loadData >> g_colors[k]; g_colors[k + 1] = g_colors[k]; g_colors[k + 2] = g_colors[k]; k=k+3; j=j+4; } } loadData.close(); void InitApp() { ... glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId); // Bind The Buffer // Load The Data glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(g_vertices)+sizeof(g_colors), 0, GL_STATIC_DRAW_ARB); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(g_vertices), g_vertices); // copy vertices starting from 0 offest glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(g_vertices), sizeof(g_colors), g_colors); // copy colours after normals ... }Code://global GLfloat *g_vertices=NULL; GLfloat *g_colors=NULL; bool Init() { ... ifstream loadData("blob3.txt");; if (!loadData) {...} else { while(getline(loadData, t, '\n')) { ++lineCount; } loadData.clear(); loadData.seekg(0, ios::beg); const int arraySize = lineCount*3; g_vertices = new GLfloat [arraySize]; g_colors = new GLfloat [arraySize]; while (j<(lineCount*4)) { for(i=0; i<3;i++) { loadData >> g_vertices[m]; m++; } loadData >> g_colors[k]; g_colors[k + 1] = g_colors[k]; g_colors[k + 2] = g_colors[k]; k=k+3; j=j+4; } } loadData.close(); void InitApp() { ... glBindBufferARB(GL_ARRAY_BUFFER_ARB, vboId); // Bind The Buffer // Load The Data glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(g_vertices)+sizeof(g_colors), 0, GL_STATIC_DRAW_ARB); glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(g_vertices), g_vertices); // copy vertices starting from 0 offest glBufferSubDataARB(GL_ARRAY_BUFFER_ARB, sizeof(g_vertices), sizeof(g_colors), g_colors); // copy colours after normals ... }




Reply With Quote