本文整理汇总了C++中oobase::SharedPtr::copy方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::copy方法的具体用法?C++ SharedPtr::copy怎么用?C++ SharedPtr::copy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类oobase::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::copy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: alloc_patch
GLsizei NinePatchFactory::alloc_patch(const glm::uvec2& size, const glm::uvec4& borders, const glm::uvec2& tex_size)
{
GLsizei patch = -1;
for (free_list_t::iterator i=m_listFree.begin(); i; ++i)
{
if (i->second == 1)
{
patch = i->first;
m_listFree.erase(i);
break;
}
else if (i->second > 1)
{
patch = i->first;
i->first += 1;
i->second -= 1;
break;
}
}
if (patch == -1)
{
if (!m_ptrProgram && !create_program())
return patch;
if (!m_ptrVAO)
{
m_ptrVAO = OOBase::allocate_shared<OOGL::VertexArrayObject,OOBase::ThreadLocalAllocator>();
if (!m_ptrVAO)
LOG_ERROR_RETURN(("Failed to allocate VAO: %s",OOBase::system_error_text(ERROR_OUTOFMEMORY)),patch);
}
m_ptrVAO->bind();
GLsizei new_size = 16;
while (new_size < m_allocated + 1)
new_size *= 2;
OOBase::SharedPtr<OOGL::BufferObject> ptrNewVertices = OOBase::allocate_shared<OOGL::BufferObject,OOBase::ThreadLocalAllocator>(GL_ARRAY_BUFFER,GL_DYNAMIC_DRAW,new_size * vertices_per_patch * sizeof(vertex_data));
OOBase::SharedPtr<OOGL::BufferObject> ptrNewElements = OOBase::allocate_shared<OOGL::BufferObject,OOBase::ThreadLocalAllocator>(GL_ELEMENT_ARRAY_BUFFER,GL_DYNAMIC_DRAW,new_size * elements_per_patch * sizeof(GLuint));
if (!ptrNewVertices || !ptrNewElements)
LOG_ERROR_RETURN(("Failed to allocate VBO: %s",OOBase::system_error_text(ERROR_OUTOFMEMORY)),patch);
if (m_ptrVertices)
ptrNewVertices->copy(0,m_ptrVertices,0,m_allocated * vertices_per_patch * sizeof(vertex_data));
if (m_ptrElements)
ptrNewElements->copy(0,m_ptrElements,0,m_allocated * elements_per_patch * sizeof(GLuint));
m_ptrVertices.swap(ptrNewVertices);
m_ptrElements.swap(ptrNewElements);
free_list_t::iterator last = m_listFree.back();
if (last)
last->second += new_size - m_allocated;
else
last = m_listFree.insert(m_allocated,new_size - m_allocated);
m_allocated = new_size;
patch = last->first;
last->first += 1;
last->second -= 1;
GLint a = m_ptrProgram->attribute_location("in_Position");
m_ptrVAO->attribute(a,m_ptrVertices,2,GL_FLOAT,false,sizeof(vertex_data),offsetof(vertex_data,x));
m_ptrVAO->enable_attribute(a);
a = m_ptrProgram->attribute_location("in_TexCoord");
if (a != -1)
{
m_ptrVAO->attribute(a,m_ptrVertices,2,GL_UNSIGNED_SHORT,true,sizeof(vertex_data),offsetof(vertex_data,u));
m_ptrVAO->enable_attribute(a);
}
m_ptrVAO->element_array(m_ptrElements);
m_ptrVAO->unbind();
}
OOBase::SharedPtr<GLuint> ei = m_ptrElements->auto_map<GLuint>(GL_MAP_WRITE_BIT,patch * elements_per_patch * sizeof(GLuint),elements_per_patch * sizeof(GLuint));
GLuint* e = ei.get();
GLuint idx = patch * vertices_per_patch;
for (size_t i=0;i<12;++i)
{
e[i*2] = static_cast<GLuint>(idx + i);
e[i*2 + 1] = static_cast<GLuint>(idx + i + 4);
}
layout_patch(patch,size,borders,tex_size);
return patch;
}