tomb18

01-18-2017, 05:19 PM

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

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