updated documentation of attribute index
This commit is contained in:
parent
9e5ecc3ace
commit
70bc054c7f
|
@ -12,13 +12,18 @@
|
|||
|
||||
/* Set the generic vertex attribute index for the attributes. It must be the same index that is
|
||||
* returned when glGetAttribLocation is given the shader program and variable name the attributes
|
||||
* will be associated with. This index may be specified in the shader source code using the location
|
||||
* layout qualifier in GLSL 3.3 and above. It can also be set automatically by OpenGL when a shader
|
||||
* program is linked. In both cases, the return value of glGetAttribLocation should be passed to
|
||||
* this function. Otherwise, this index can be an arbitrary choice that is not greater than
|
||||
* GL_MAX_VERTEX_ATTRIBS, in which case it would be explicitly passed to glBindAttribLocation. It
|
||||
* can then be passed to glVertexAttribPointer to set the properties of the attributes on the
|
||||
* GPU. */
|
||||
* will be associated with. The bind class member functions can automatically do that, and they
|
||||
* should be used instead of this function if possible.
|
||||
*
|
||||
* The index may be specified to GL in the shader source code using the location layout qualifier
|
||||
* in GLSL 3.3 and above. It can also be set automatically by GL when a shader program is linked.
|
||||
* In both cases, the return value of glGetAttribLocation should be passed to this function.
|
||||
* Otherwise, this index can be an arbitrary choice that is not greater than GL_MAX_VERTEX_ATTRIBS,
|
||||
* in which case it would be explicitly passed to glBindAttribLocation.
|
||||
*
|
||||
* Once assigned, the index can be passed to glVertexAttribPointer to set the properties of the
|
||||
* attributes on the GPU, either manually or automatically through the add member function in the
|
||||
* VBO class. */
|
||||
void sb::Attributes::index(GLuint index)
|
||||
{
|
||||
attribute_index = index;
|
||||
|
@ -252,7 +257,8 @@ void sb::Attributes::extend(const Attributes& other, std::size_t count)
|
|||
* prevent it being looked up with arguments other than attributes. */
|
||||
std::ostream& sb::operator<<(std::ostream& out, const Attributes& attributes)
|
||||
{
|
||||
out << "<Attributes (#" << attributes.index() << ", " << attributes.size() << " bytes, ";
|
||||
out << "<Attributes (#" << attributes.index() << ", " << attributes.dimensions() << "D, " <<
|
||||
attributes.size() << " bytes, ";
|
||||
std::visit([&] (const auto& vector) {
|
||||
if constexpr (!std::is_same_v<std::decay_t<decltype(vector)>, std::monostate>)
|
||||
{
|
||||
|
|
|
@ -53,8 +53,7 @@ GLintptr VBO::add(sb::Attributes& attributes)
|
|||
attributes.index(), attributes.dimensions(), attributes.type(), attributes.normalized(), 0, reinterpret_cast<GLvoid*>(offset));
|
||||
/* Debug */
|
||||
std::ostringstream pointer_message;
|
||||
pointer_message << "After defining attribute pointer for <Attributes (" << attributes.dimensions() << "D, id: " <<
|
||||
attributes.index() << ", size:" << attributes.size() << ")>";
|
||||
pointer_message << "After defining pointer for " << attributes;
|
||||
sb::Log::gl_errors(pointer_message.str());
|
||||
/* Increase offset */
|
||||
offset += attributes.size();
|
||||
|
|
Loading…
Reference in New Issue