| 140 | } |
| 141 | |
| 142 | void vtkOpenGLVertexArrayObject::Bind() |
| 143 | { |
| 144 | // Either simply bind the VAO, or emulate behavior by binding all attributes. |
| 145 | if (!this->Internal->IsReady()) |
| 146 | { |
| 147 | this->Internal->Initialize(); |
| 148 | } |
| 149 | if (this->Internal->IsReady() && this->Internal->Supported) |
| 150 | { |
| 151 | glBindVertexArray(this->Internal->HandleVAO); |
| 152 | } |
| 153 | else if (this->Internal->IsReady()) |
| 154 | { |
| 155 | Private::AttributeMap::const_iterator it; |
| 156 | for (it = this->Internal->Attributes.begin(); it != this->Internal->Attributes.end(); ++it) |
| 157 | { |
| 158 | std::vector<VertexAttributes>::const_iterator attrIt; |
| 159 | glBindBuffer(GL_ARRAY_BUFFER, it->first); |
| 160 | for (attrIt = it->second.begin(); attrIt != it->second.end(); ++attrIt) |
| 161 | { |
| 162 | int matrixCount = attrIt->IsMatrix ? attrIt->Size : 1; |
| 163 | for (int i = 0; i < matrixCount; ++i) |
| 164 | { |
| 165 | glEnableVertexAttribArray(attrIt->Index + i); |
| 166 | glVertexAttribPointer(attrIt->Index + i, attrIt->Size, attrIt->Type, attrIt->Normalize, |
| 167 | attrIt->Stride, BUFFER_OFFSET(attrIt->Offset + attrIt->Stride * i / attrIt->Size)); |
| 168 | if (attrIt->Divisor > 0) |
| 169 | { |
| 170 | #ifdef GL_ES_VERSION_3_0 |
| 171 | glVertexAttribDivisor(attrIt->Index + i, 1); |
| 172 | #else |
| 173 | if (GLAD_GL_ARB_instanced_arrays) |
| 174 | { |
| 175 | glVertexAttribDivisorARB(attrIt->Index + i, 1); |
| 176 | } |
| 177 | #endif |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | glBindBuffer(GL_ARRAY_BUFFER, 0); |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | void vtkOpenGLVertexArrayObject::Release() |
| 187 | { |
no test coverage detected