Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: glsl automatic generic attributes binding

  1. #1
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273

    glsl automatic generic attributes binding

    Hello, I'm trying to do the automatic generic attributes binding, and I have somre problems...:
    First: Can I set up an automatic binding using a string name for this array?
    Second: If I can do 'First', how can do this?
    I have readed the specs, but I'm unable to figure out how I could do this.
    Thanks in adavance.
    "!I don't know... fly casual"

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: glsl automatic generic attributes binding

    What do you mean with automatic?

    Let's say you have this program
    Code :
    attribute vec4 whatsyourname;
    void main(void)
    {
      gl_Position = gl_ModelViewProjectionMatrix * whatsyourname;
    }
    Then generic attribute binding is done with
    glBindAttribLocationARB(programObject, 0, "whatsyourname");
    glLinkProgramARB(programObject); // and check link status.
    glUseProgramObjectARB(programObject);

    And now the program will trigger each time you call e.g. glVertexAttrib3fARB(0, x, y, z); or send data in vertex arrays 0.
    Similar for the other 15 attributes, but remember, only attribute 0 triggers.

  3. #3
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273

    Re: glsl automatic generic attributes binding

    With automatic I mean that I dont want to use glBindAttribLocationARB(programObject, 0, "whatsyourname"); to specify the index (or location, in this example, the 0) of the custom attribute array. I want let OpenGl gives me an avalaible index for that attrib array.

    This must be by this way because I dont know how many attributes will be builded by the user, and I need an automatic method to assign them.

    P.D: The host application will apply the attributes, and a plugin will build any number of them. (I do this to allow things like tangent data for ppl or bone stuff for skinning in the Shader Designer)
    "!I don't know... fly casual"

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,453

    Re: glsl automatic generic attributes binding

    I haven't seen an interface for that in OpenGL.
    You have a limited amount of vertex attributes, as long as you don't exceed that number you can bind these attributes in any order you want/need, excepth that attribute zero triggers the pipeline and needs to come last.
    I think I don't see the problem.
    One of you modules need to know exactly what it's doing, including what is bound to which attribute (the host would be my choice) and the plugin needs to be informed which attribute index to use if it sends data directly to OpenGL.

  5. #5
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273

    Re: glsl automatic generic attributes binding

    I have found it. If I dont call glBindAttribLocationARB before linking the program, and after linking the program I call glGetAttribLocation(program,"varName"); opengl returns me a unused slot to place my attribute array (if opengl cans), so I can bind an arbitrary number of vertex attributes arrays without specifing the index (under the top limit).

    Sorry if I cant explain me very well. My english aren't very good
    "!I don't know... fly casual"

  6. #6
    Intern Contributor
    Join Date
    Sep 2001
    Location
    Marlboro MA
    Posts
    90

    Re: glsl automatic generic attributes binding

    Originally posted by Ffelagund:
    I have found it. If I dont call glBindAttribLocationARB before linking the program, and after linking the program I call glGetAttribLocation(program,"varName");
    Exactly. After linking, you can also use glGetActiveAttribARB to find all the active attributes used by a shader. If you don't like where the attributes were bound automatically, you can bind them where you'd like and relink them to your favorite glVertexAttrib indices.

    -mr. bill

  7. #7
    Intern Contributor
    Join Date
    Jan 2004
    Location
    bristow, VA, US
    Posts
    53

    Re: glsl automatic generic attributes binding

    glGetVertexAttribLocation should provide you with the index. But currently generic vertex bindings don't work on ATI and nVidia drivers. so your code won't work for now. ATI will fix this in a future driver release. So if your code crashes, just know that it is the driver. This piece of information will save you hours and hours of frustration trying to get your code to work and not knowing why it keeps crashing.

  8. #8
    Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Spain
    Posts
    273

    Re: glsl automatic generic attributes binding

    Thanks, I've read another post where was talking about this.
    I have tested the program with two generic vertex attibutes (tangents and binornals) in NV,3dlabs and ATI cards and I haven't noticed anything bad, but, maybe the problems comes with a huge number of data on the attributes (or too much attributes?).
    "!I don't know... fly casual"

  9. #9
    Intern Contributor
    Join Date
    Jan 2004
    Location
    bristow, VA, US
    Posts
    53

    Re: glsl automatic generic attributes binding

    What you say is very interesting. I don't think that data set size would have any effect on the code crashing. But something else comes to mind ... are you using VBOs to store your data, because if you are not and just passing plain vanilla pointers then the problem might be with the VBO objects compatibility with generics.
    Thanks in advance.

  10. #10
    Intern Contributor
    Join Date
    Jan 2004
    Location
    bristow, VA, US
    Posts
    53

    Re: glsl automatic generic attributes binding

    Also which driver version are you using on your ATI card ? I am using 4.3.

Posting Permissions

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