I have found that with my application, using VBOs and glDrawRangeElements to render objects causes (CPU) memory to constantly decrease (the more objects, the faster).
If I comment out the call to glDrawRangeElements but have all the other code be executed, no memory gets consumed.
Any idea what this may be causing this and how I can get rid of it?
Hardware: Radeon 4870 1GB, WinXP SP3, 4 GB RAM, Catalyst 9.4
Status unchanged with Cat. 9.6
I cannot detect anything unusual in my code.
My code is about:
glGenBuffersARB (1, &m_vboDataHandle); glBindBufferARB (GL_ARRAY_BUFFER_ARB, m_vboDataHandle); glBufferDataARB (GL_ARRAY_BUFFER, m_nFaceVerts * sizeof (CRenderVertex), NULL, GL_STATIC_DRAW_ARB); m_vertBuf.SetBuffer (reinterpret_cast<CRenderVertex*> (glMapBufferARB (GL_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB)), 1, m_nFaceVerts); glGenBuffersARB (1, &m_vboIndexHandle); glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, m_vboIndexHandle); glBufferDataARB (GL_ELEMENT_ARRAY_BUFFER_ARB, m_nFaceVerts * sizeof (short), NULL, GL_STATIC_DRAW_ARB); m_index.SetBuffer (reinterpret_cast<short*> (glMapBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, GL_WRITE_ONLY_ARB)), 1, m_nFaceVerts);
After that, the buffers are initialized and once that’s done, they are unmapped.
glUnmapBufferARB (GL_ARRAY_BUFFER_ARB); glBindBufferARB (GL_ARRAY_BUFFER_ARB, 0); glUnmapBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB); glBindBufferARB (GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
Before rendering, the VBO buffers are of course bound again. Here’s the call to glDrawRangeElements:
glDrawRangeElements (GL_TRIANGLES, 0, pm->m_nFaceVerts - 1, nVerts, GL_UNSIGNED_SHORT, 0);
pm->m_nFaceVerts - 1 is the max. vertex index value of the entire model.
nVerts is the count of the vertices to be rendered.
I am getting no errors returned from OpenGL (checking them all over the place). Same problem when using glDrawElements instead.