Okay after playing with the stuff a bit I made some progress but still have some interrogations:
I managed to no use and client-side memory at all for data structures (my guess was that it restricted the contiguous memory available) and use VBOs instead. To take an arbitrary object as an example I get the following VBOs:
Vertex 5663304 x 3 floats = 68MB
Normal 5663304 x 3 floats = 68MB
texcoord 5663304 x 2 shorts = 23MB
data1 5663304 x 3 floats = 68MB
data2 5663304 x 3 floats = 68MB
EBO 5663304 x 1 int = 23MB
EBO 353956 x 1 int = 1.4MB
I switched the texcoords from floats to shorts using the following:
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glScalef(1.0/static_cast<float>(m_iWidth), 1.0/static_cast<float>(m_iHeight), 1);
I will also look into using glTexGen.
On the whole, I can presently load 10 such objects on screen without problems so it would be Mission Accomplished if I didn’t have other problems. The problems star appearing when I modify the vertex data. I can do it as many times as I wish for one of the objects without any problems but as soon as I try it on another object afterward, I get GL_OUT_OF_MEMORY from my glMapBufferARB calls and stuff starts disapearing.
But when I modify the data, i carefully release the mapped memory so it shouldn’t happen right? My map/unmap calls seem to be well balanced and I tried a few different combinations of STATIC/DYNAMIC/STREAM + DRAW/COPY/READ to no avail:
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboVertex);
pglBufferDataARB(GL_ARRAY_BUFFER_ARB, m_iNbVertices*sizeof(vertex_t), 0, GL_STATIC_DRAW); //flag as dirty
float ptr = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData1);
float ptrData1 = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData2);
float ptrData2 = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
//Modify data in the ptr buffer
pglBindBufferARB(GL_ARRAY_BUFFER, 0);
CalcNormals();
I also tried the following form with no differences:
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboVertex);
pglBufferDataARB(GL_ARRAY_BUFFER_ARB, m_iNbVertices*sizeof(vertex_t), 0, GL_STATIC_DRAW); //flag as dirty
float ptr = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB);
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData1);
float ptrData1 = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB);
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData2);
float ptrData2 = (float)pglMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB);
//Modify data in the ptr buffer
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboVertex);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData1);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
pglBindBufferARB(GL_ARRAY_BUFFER_ARB, m_vboData2);
pglUnmapBufferARB(GL_ARRAY_BUFFER_ARB); // release pointer to mapping buffer
pglBindBufferARB(GL_ARRAY_BUFFER, 0);
CalcNormals();
I tried using smaller datatypes (GL_HALF_FLOAT, GL_BYTE, GL_SHORT) for the normals but visually it was not good. I’m still not using a shader so that may be a cause of problem no?