pccash
pccash

Reputation: 11

opengl difference setting value in layout location or uniform variable

i am trying to get myself familiar with opengl programming. I cant stop wondering when should i use layout for variable input to a shader (with glVertexAttribPointer) vs just setting an uniform with glUniform. What are the advantage and when should i use one over the other? kind regards

Upvotes: 0

Views: 501

Answers (1)

Sean Burton
Sean Burton

Reputation: 960

It depends what you want to do with the value. If you want to pass in a single value to the shader, which won't change for each vertex, then you use a uniform. If you want to pass in multiple values so each vertex can have a different value, then you use an attribute pointer.

Upvotes: 2

Related Questions