View Full Version : glsl automatic generic attributes binding
03-26-2004, 01:06 AM
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.
03-26-2004, 03:27 AM
What do you mean with automatic?
Let's say you have this program
attribute vec4 whatsyourname;
gl_Position = gl_ModelViewProjectionMatrix * whatsyourname;
}Then generic attribute binding is done with
glBindAttribLocationARB(programObject, 0, "whatsyourname");
glLinkProgramARB(programObject); // and check link status.
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.
03-26-2004, 04:17 AM
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)
03-26-2004, 06:27 AM
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.
03-26-2004, 06:33 AM
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 :)
03-26-2004, 07:24 AM
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.
03-26-2004, 08:05 AM
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.
03-26-2004, 09:56 AM
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?).
03-26-2004, 10:21 AM
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. :)
03-26-2004, 10:26 AM
Also which driver version are you using on your ATI card ? I am using 4.3.
03-26-2004, 10:28 AM
Just only glDrawElements for the indexed geometry/texcoords/vertexNormals.
I'm not using VBO, VAO, DL or anything else.
Edit: I have not an ATI or NV card. I have a 3DLabs Wildcat VP 560 (drivers version: 3.01-0734)
Edit2: But I have tested the tangents and binormals in NV and ATI cards (I dont remember the driver version, sorry)
03-26-2004, 10:35 AM
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.