Jump to content

  • Log In with Google      Sign In   
  • Create Account

Default value for attributes


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 k.pedersen   Members   -  Reputation: 100

Like
0Likes
Like

Posted 13 April 2012 - 04:02 AM

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
Wavefront Animation Studio - Create simple animations for .obj 3D models.
libwavefront - Open-source C++/OpenGL library to load animated .obj models.

Sponsor:

#2 Lichtso   Members   -  Reputation: 118

Like
0Likes
Like

Posted 17 April 2012 - 11:26 AM

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);


#3 tanzanite7   Members   -  Reputation: 1378

Like
0Likes
Like

Posted 19 April 2012 - 02:24 AM

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).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS