Results 1 to 5 of 5

Thread: VBO's -> data parameter

  1. #1
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    VBO's -> data parameter

    Hi,
    I want to use vertex buffer objects in my program, but i'm a little confused about the parameter data of glBufferData.
    On the nehe example: http://nehe.gamedev.net/data/lessons....asp?lesson=45
    In that code, they use a class, with three variables(x, y and z), and they give an array of that classes to the function glBufferData.
    But on the man page of glBufferData, it says nothing about classes or whatever, and the way I would think data has to be stored is an array of floats, where the size of the array equals to the number of vertices to render times three.
    Can somebody clear this up a bit?
    Thanx in advance,
    Hylke

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: VBO's -> data parameter

    The best way to understand VBO is to read carefully the specs. You don't need any classes. Why would you need them since GL is written in C but not C++ ? Classes are made to make things easier, generally

    For BufferData, it is simple: give the size in bytes, a pointer that points to the start of the array to copy, and the usage. The size is like any other allocating command, like malloc. You can't give the number of vertices*3 just because you can not only put float in VBO but any other types which do not have the same sizes. So you'll give vertices*3*sizeof (GLfloat) for example.

  3. #3
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: VBO's -> data parameter

    Thank you for your reply,
    But I still have a question:
    How can OpenGL fetch the data from a class/struct?

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: VBO's -> data parameter

    This question relies from how your programming language stores the data in memory not from GL. So I guess a good book or a good documentation about your programming language will definately help you increase your understandings.

    Anyway, generally in C and C++ when you write something like this:

    Code :
    struct S{
       float a;
       float b;
       float c;
    };
    all a,b and c will be memory aligned (I said generally because I could never ensured it anywhere). In this case, simply put the adress of a when you fetch.
    What's an obligation from the standards is that all struct S will have the same size (here 3*sizeof (float)).

    Hope that could help.

  5. #5
    Senior Member Regular Contributor
    Join Date
    May 2004
    Location
    Renkum
    Posts
    193

    Re: VBO's -> data parameter

    I already figured it would be something like that.
    Well, thanks.
    Hylke

Similar Threads

  1. Reading value of constant parameter
    By juramraz in forum OpenCL
    Replies: 0
    Last Post: 08-15-2017, 01:54 AM
  2. Using the cl_context_properties parameter
    By riven609 in forum OpenCL
    Replies: 1
    Last Post: 07-21-2009, 12:27 PM
  3. which parameter can a texture object keep
    By aQ in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 06-06-2005, 05:36 AM
  4. VAR parameter question
    By aphex in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 09-19-2002, 09:11 PM
  5. Parameter in glColor3f 1, 0, 0 by Example...
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-01-2001, 05:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean