lilroo
lilroo

Reputation: 3128

does glVertexAttribDivisor affect non-instanced glDrawArrays calls?

Do setting vertex attribute divisors with glVertexAttribDivisor affect non-instanced draw calls EG glDrawArrays

Upvotes: 3

Views: 424

Answers (2)

lilroo
lilroo

Reputation: 3128

glDrawArrays or DrawArraysOneInstance (from the core spec) will draw one instance for all the primitives it draws. This means that the gl_instance_id will remain 0 for the whole draw call. Instanced attributes will only have their first instance accessed for all primitives. (although it is possible to provide a base offset to gl_instance_id)

For Example: a call to glDrawArrays to draw 6 triangle primitives, will only use the first instance of any instanced attributes for every primitive that it draws.

It's not possible to have attributes that advance per primitive.

For more details, see section 10.4 of the opengl4.6 core spec

Upvotes: 1

Nicol Bolas
Nicol Bolas

Reputation: 473477

All "non-instanced" draw calls are instanced draw calls. They merely draw one instance, starting with a base instance of 0. So instanced attributes still act like instanced attributes.

Upvotes: 3

Related Questions