BufferSubData seems to have a mind of its own!

Hi,
I’ve run into a problem which I cannot seem to solve.
I am plotting a 3D surface in real time. The surface starts as a plane in XZ with heights given by Y.
This plane originates as a triangle strip with indices. The result is I get a vertex array with coordinates like this (simple case of x = 3 and z = 3

vertexArray[0] = <-1, Height, +1>
vertexArray[1] = <0, Height, +1>
vertexArray[2] = <1, Height, +1>
vertexArray[3] = <-1,Height, 0>
vertexArray[4] = <0 , Height, 0>
vertexArray[5] = <1, Height, 0>
vertexArray[6] = <-1, Height, -1>
vertexArray[7] = <0, Height, -1>
vertexArray[8] = <1, Height, -1>

So you have a nice 3x3 grid and it plots fine.
Now I want to update this i real time (the actual size is 2048x100) so I update the first row starting at vertexArray[0] to vertexArray[2] and then I do a

vbo.BufferSubData(vertexArray).
So you think it would update the first row. However it updates the backrow! Even though I can check the individual elements of the vertexArray and they are correct! If I do it again to the first row, it then DOES update the first row.
I have tried three times, every time changing my algorithm and it always behaves the same!
The code is as follows, with the correct vertexArray.


            Gl.UseProgram(plottingProgram);

            plottingProgram["model_matrix"].SetValue(Matrix4.CreateRotationY(yangle) * Matrix4.CreateRotationX(xangle));

            if (dataAvailable)
            {
                CircularBuffer.UpdateVertexArray(); //data is updated here.  100% sure it is correct!
                dataAvailable = false;
            }

            spectrumVBO.BufferSubData(vertexBuffer); //vertexBuffer is an array with x,y,z data.  x,z is always the same

            Gl.BindBufferToShaderAttribute(spectrumVBO, plottingProgram, "vertexPosition");

            Gl.BindBuffer(spectrumIndicesVBO);
            Gl.DrawElements(BeginMode.TriangleStrip, spectrumIndicesVBO.Count, DrawElementsType.UnsignedInt, IntPtr.Zero);


Is there something I am missing here?
Thanks

This isn’t an OpenGL API call. This is. Please list the code with wrapper calls like this expanded to GL calls.

Hi,
Here is what I got from looking into the library…
GLSubBufferData(BufferTarget, (IntPtr)offset, (IntPtr)size, handle.AddrOfPinnedObject());
where buffer target is arraybuffer.

Tom

One way or the other, I suggest you get a call trace of the actual GL calls.

It’s hard to tell from the wrapper APIs you’ve got posted what’s going on. As a shot-in-the-dark, look at the values provided for the arguments of glBufferSubData.

another shot-in-the-dark, normally you can control at what offset the data should be filled in / replaced, maybe you missed something in that respect

Hi
The hints you guys gave were enough to show me that the GLSubBufferData was being passed the right parameters. So I changed my circular buffer which I was sure was 100% correct. Turns out it was only 80% correct lol.
Thanks!