Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Using VBOs

  1. #1
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    2

    Using VBOs

    Hallo,

    I hope that somebody can help me with my problem. I read and searched for information several days about VBOs but meanwhile I'm totally confused.

    I want to show measured data with OpenGL with the help of VBOs.
    The data point consists of one X value and one Y value and I have 50000 points.

    I created an double array which is in format:

    double[] data = new double[] {x0,y0,x1,y1,...,x49999,y49999}

    //Create Buffer works
    int[] buffers = new int[1];
    Gl.glGenBuffers(buffers.Length, buffers);

    //Bind Buffer works
    Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, buffers[0]);
    Gl.glBufferData(Gl.GL_ARRAY_BUFFER, (IntPtr)(data.Length * sizeof(double)), data, Gl.GL_STATIC_DRAW);

    //Nothing works from here - please help with this
    Gl.glVertexPointer(2, Gl.GL_DOUBLE, 0, 0);
    Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
    Gl.glDrawArrays(Gl.GL_LINE_STRIP, 0, 50000);

    //Cleaning everything
    Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
    Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, 0);

    I searched and googled and found a lot but I am confused and totally lost. Can smoeone put me on the right way again?

    Thanks.

    Dave

  2. #2
    Junior Member Newbie
    Join Date
    May 2010
    Posts
    2

    Re: Using VBOs

    Maybe writing in this forum helped me to solve my problem. Here are the code fragments that worked for me. On of my problem was probably C#/Tao framework.

    int[] buffers = new int[1];
    Gl.glGenBuffers(buffers.Length, buffers);

    Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, bufferName);
    Gl.glBufferData(Gl.GL_ARRAY_BUFFER, (IntPtr)(data.Length * sizeof(double)), data, Gl.GL_STATIC_DRAW);

    //Most important is the last parameter
    //0 is not IntPtr.Zero !!!
    Gl.glVertexPointer(2, Gl.GL_DOUBLE, 0, IntPtr.Zero);
    Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);

    Gl.glDrawArrays(Gl.GL_LINES, 0, data.Length/2);

    Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
    Gl.glBindBuffer(Gl.GL_ARRAY_BUFFER, 0);

    That's it.

    Dave

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    941

    Re: Using VBOs

    I would suggest you not to use double floats, but single ones as, except the latest generation of GPUs, it is not supported in hardware.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •