Ejemplo n.º 1
0
  void Mesh::addBuffer(GLfloat const *buffer, internal::AttributeAccessor attribute, Shader::Format format)
  {
    if(attributeIndex(attribute) != -1)
      throw log(__FILE__, __LINE__, LogType::error, "Trying to add a buffer to a mesh that is already added");

    d_additionalVBOs.emplace_back(ListAccessor<GLfloat>{d_numOfVertices * internal::formatSize(format), buffer});
    d_formats.push_back({attribute, format});
  }
Ejemplo n.º 2
0
  void Mesh::updateBuffer(GLfloat const *buffer, internal::AttributeAccessor attribute)
  {
    int index = attributeIndex(attribute);

    if(index == -1 || (index != 0 && d_additionalVBOs[index - 1].size() == 0) || (index == 0 && d_interleavedVBO.size() == 0))
      throw log(__FILE__, __LINE__, LogType::error, "Unable to call Mesh::updateBuffer(buffer, attribute) on an attribute that has not been added first");

    uint formatS = internal::formatSize(d_formats[index].second);

    if(index == 0)
      d_interleavedVBO.update({d_numOfVertices * formatS, buffer});
    else
      d_additionalVBOs[index - 1].update({d_numOfVertices * formatS, buffer});
  }
void VertexAttributeBindingImplementation_Legacy::finish(const VertexAttributeBinding * binding) const
{
    assert(bindingData(binding) != nullptr);

    vao(binding)->bind();

    void * offset = nullptr;

    if (vbo(binding))
    {
        vbo(binding)->bind(GL_ARRAY_BUFFER);
        const auto offset64 = static_cast<GLuint64>(bindingData(binding)->baseoffset + bindingData(binding)->format.relativeoffset);
        offset = reinterpret_cast<void *>(offset64);
    }
    else
    {
        Buffer::unbind(GL_ARRAY_BUFFER);
    }

    const GLint attribute = attributeIndex(binding);

    switch (bindingData(binding)->format.method)
    {
    case Format::Method::I:
        glVertexAttribIPointer(attribute, bindingData(binding)->format.size, bindingData(binding)->format.type
            , bindingData(binding)->stride, offset);
        break;

    case Format::Method::L:
        glVertexAttribLPointer(attribute, bindingData(binding)->format.size, bindingData(binding)->format.type
            , bindingData(binding)->stride, offset);
        break;

    default:
        glVertexAttribPointer(attribute, bindingData(binding)->format.size, bindingData(binding)->format.type
            , bindingData(binding)->format.normalized, bindingData(binding)->stride, offset);
    }
}
const MetaAttribute &MetaRecord::metaAttribute(
	const CSSM_DB_ATTRIBUTE_INFO &inAttributeInfo) const
{
	return *mAttributeVector[attributeIndex(inAttributeInfo)];
}