Jump to content
  • Advertisement
Sign in to follow this  
k.pedersen

Default value for attributes

This topic is 2400 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

Just checking if a function like glVertexAttrib3f() is meant to set the default value for an in attribute for a shader.

For example, if I am drawing a cube which doesnt actually have texture coordinates but my shader usually supports them, would I have to have multiple shaders or could I do something like the following...


glVertexAttrib3f(inTexCoords, 1, 2, 3);


And expect the attribute in my shader to have the vec3 value of 1, 2, 3?

So far it just seems to not draw anything, so I am wondering if this is correct functionaility or if I have a bug somewhere...

Cheers,

Karsten

Share this post


Link to post
Share on other sites
Advertisement
Hi,

I don't know anything about a function which can set a default value for the attributes.
But I know that, if no attribute is set, the values are 0 by default and if you want to disable single attributes, the best way to do this is using a uniform variable.
Also, to use VBOs is recommended so the function call should be:

void glVertexAttribPointer( GLuint index,
GLint size,
GLenum type,
GLboolean normalized,
GLsizei stride,
const GLvoid * pointer);

Share this post


Link to post
Share on other sites

glVertexAttrib3f(inTexCoords, 1, 2, 3);
And expect the attribute in my shader to have the vec3 value of 1, 2, 3?

Yes. I use them as per-draw call constants (the rest of the attributes are sourced from vertex buffers) for example (instead of uniforms). In that use they are commonly called "dangling attributes".

Edit: Oh, and no - you do not need to set a default value. Every vertex attribute has already a default value (all 0 most likely, or whatever else it was explicitly set to).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!