Hi. I really need some help with my vertex arrays. Everything seems to work fine, I have multitexture running fine and so..
But as soon as I try to draw anything above the 20th (or something like that) row the program crashes! I can’t even draw a single element or the program crashes… And I have no idea why! I have tried to write my vertex and indice array to a file and they all seems okey. The map is 256 wide and high. I have the arrays as follow:
Here is the code for setting up the arrays:Code :float g_vertex[MAP_SIZE*MAP_SIZE][3]; float g_texture0[MAP_SIZE*MAP_SIZE][2]; float g_texture1[MAP_SIZE*MAP_SIZE][2]; GLuint g_index[MAP_SIZE*MAP_SIZE*2];
And here is the code for drawing..Code :int index=0; int currentVertex=0; const float divv=256; const float divvd=4; int z=0; int x=0; for(z=0; z < MAP_SIZE; z++) { for (x=0; x < MAP_SIZE; x++) { //jobbar med vertexarna g_vertex[x+z*MAP_SIZE][0] = x; g_vertex[x+z*MAP_SIZE][1] = Height(pHeightMap, x, z); g_vertex[x+z*MAP_SIZE][2] = z; //textur nummer ett (den stora) g_texture0[x+z*MAP_SIZE][0] = x / divv; g_texture0[x+z*MAP_SIZE][1] = z / divv; //textur nummer två (detail) g_texture1[x+z*MAP_SIZE][0] = x / divvd; g_texture1[x+z*MAP_SIZE][1] = z / divvd; } } for(z=0; z < (MAP_SIZE - 1); z++) { for (x=0; x < MAP_SIZE; x++) { currentVertex = z * MAP_SIZE + x; g_index[index++] = currentVertex + MAP_SIZE; g_index[index++] = currentVertex; } }
And this will cause the program to crash, and there is no difference with locked arrays or not… And everything works fine if I only draw the first 20 rows, so I manage the arrays and so fine I think…Code :for(int row=0; row <= MAP_SIZE - 1; row++) { glDrawElements(GL_TRIANGLE_STRIP, MAP_SIZE * 2, GL_UNSIGNED_INT, &g_index[row*(MAP_SIZE * 2)]); }
Is there anyone with a good answer to my problem?? I’m tearing my hair of here!



)