| 247 | } |
| 248 | |
| 249 | bool vtkOpenGLVertexArrayObject::AddAttributeArrayWithDivisor(vtkShaderProgram* program, |
| 250 | vtkOpenGLBufferObject* buffer, const std::string& name, int offset, size_t stride, |
| 251 | int elementType, int elementTupleSize, bool normalize, int divisor, bool isMatrix) |
| 252 | { |
| 253 | if (!program) |
| 254 | { |
| 255 | vtkErrorMacro("attempt to add attribute without a program for attribute " << name); |
| 256 | return false; |
| 257 | } |
| 258 | |
| 259 | // Check the program is bound, and the buffer is valid. |
| 260 | if (!program->isBound()) |
| 261 | { |
| 262 | vtkErrorMacro("attempt to add attribute without a bound program for attribute " << name); |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | if (buffer->GetHandle() == 0) |
| 267 | { |
| 268 | vtkErrorMacro("attempt to add attribute without a handleless buffer for attribute " << name); |
| 269 | return false; |
| 270 | } |
| 271 | |
| 272 | if (buffer->GetType() != vtkOpenGLBufferObject::ArrayBuffer) |
| 273 | { |
| 274 | vtkErrorMacro("attempt to add attribute without an array buffer for attribute " << name); |
| 275 | return false; |
| 276 | } |
| 277 | |
| 278 | // Perform initialization if necessary, ensure program matches VAOs. |
| 279 | if (this->Internal->HandleProgram == 0) |
| 280 | { |
| 281 | this->Internal->HandleProgram = static_cast<GLuint>(program->GetHandle()); |
| 282 | } |
| 283 | if (!this->Internal->IsReady() || |
| 284 | this->Internal->HandleProgram != static_cast<GLuint>(program->GetHandle())) |
| 285 | { |
| 286 | vtkErrorMacro("attempt to add attribute when not ready for attribute " << name); |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | const GLchar* namePtr = static_cast<const GLchar*>(name.c_str()); |
| 291 | VertexAttributes attribs; |
| 292 | attribs.Index = program->FindAttributeArray(namePtr); |
| 293 | attribs.Offset = offset; |
| 294 | attribs.Stride = static_cast<GLsizei>(stride); |
| 295 | attribs.Type = convertTypeToGL(elementType); |
| 296 | attribs.Size = elementTupleSize; |
| 297 | attribs.Normalize = normalize; |
| 298 | attribs.IsMatrix = isMatrix; |
| 299 | attribs.Divisor = divisor; |
| 300 | |
| 301 | if (attribs.Index == -1) |
| 302 | { |
| 303 | vtkErrorMacro("attempt to add attribute not found in program for attribute " << name); |
| 304 | return false; |
| 305 | } |
| 306 |
no test coverage detected