Hi!
I am using OpenGL > C# > Tao, for drawing large datasets. I managed to draw all data using display lists, but I want more flexibility, because I have to be able to show/hide certain points.
I fill a 2D array with MyVertex, which is a struct containing x, y and z coordinates. When drawing this it only shows one vertex (Gl_POINTS) at the centre of the screen. Help appreciated.
* I have tried this, using one big array containing vertices data. Where every coordinate is at its own index. So MyVertex vertices = new MyVertex[nrChannel * DRAWDATASIZE * 3]. This gave me the same results.
int vboId;
MyVertex[,] vertices;
struct MyVertex
{
public float x, y, z;
};
...
I am filling the buffer with vertices here:
vertices = new MyVertex[nrChannels, DRAWDATASIZE]; //nrChannels = 10, DRAWDATASIZE = 100
for (Byte channel = 0; channel < nrChannels; channel++)
{
for (int position = 0; position < DRAWDATASIZE; position++)
{
vertices[channel, position].x = position;
vertices[channel, position].y = depth; // Depth has been initialized, but not been included in the code snippet
vertices[channel, position].z = 0;
}
}
// generate a new VBO and get the associated ID
Gl.glGenBuffers(1, out vboId);
// bind VBO in order to use
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, vboId);
// upload data to VBO
Gl.glBufferData(Gl.GL_ARRAY_BUFFER, (IntPtr)(sizeof(float) * 3 * vertices.Length), vertices, Gl.GL_STATIC_DRAW);
Then Drawing the scene:
...
Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, vboId);
Gl.glVertexPointer(3, Gl.GL_FLOAT, 0, vertices);
Gl.glDrawArrays(Gl.GL_POINTS, 0, vertices.Length);
...
What am I doing wrong?
Regards,
Bas