当前位置: 首页>>代码示例>>C++>>正文


C++ vogl_context_info::get_max_vertex_attribs方法代码示例

本文整理汇总了C++中vogl_context_info::get_max_vertex_attribs方法的典型用法代码示例。如果您正苦于以下问题:C++ vogl_context_info::get_max_vertex_attribs方法的具体用法?C++ vogl_context_info::get_max_vertex_attribs怎么用?C++ vogl_context_info::get_max_vertex_attribs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vogl_context_info的用法示例。


在下文中一共展示了vogl_context_info::get_max_vertex_attribs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: snapshot

bool vogl_vao_state::snapshot(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 handle, GLenum target)
{
    VOGL_FUNC_TRACER

    VOGL_NOTE_UNUSED(target);
    VOGL_NOTE_UNUSED(remapper);

    VOGL_CHECK_GL_ERROR;

    clear();

    VOGL_ASSERT(handle <= cUINT32_MAX);

    m_snapshot_handle = static_cast<GLuint>(handle);

    // TODO: Core profile support
    m_has_been_bound = handle ? (GL_ENTRYPOINT(glIsVertexArray)(static_cast<GLuint>(handle)) != 0) : true;

    if (m_has_been_bound)
    {
        vogl_scoped_binding_state orig_binding(GL_VERTEX_ARRAY);

        GL_ENTRYPOINT(glBindVertexArray)(m_snapshot_handle);
        VOGL_CHECK_GL_ERROR;

        m_element_array_binding = vogl_get_gl_integer(GL_ELEMENT_ARRAY_BUFFER_BINDING);

        m_vertex_attribs.resize(context_info.get_max_vertex_attribs());

        for (uint32_t i = 0; i < context_info.get_max_vertex_attribs(); i++)
        {
            vogl_vertex_attrib_desc &desc = m_vertex_attribs[i];

            desc.m_array_binding = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING);
            desc.m_enabled = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED) != 0;
            desc.m_size = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_SIZE);
            desc.m_type = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_TYPE);
            desc.m_normalized = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED) != 0;
            desc.m_stride = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE);
            desc.m_integer = vogl_get_vertex_attrib_int(i, GL_VERTEX_ATTRIB_ARRAY_INTEGER) != 0;
            desc.m_divisor = vogl_get_vertex_attrib_uint(i, GL_VERTEX_ATTRIB_ARRAY_DIVISOR);

            GLvoid *ptr = NULL;
            GL_ENTRYPOINT(glGetVertexAttribPointerv)(i, GL_VERTEX_ATTRIB_ARRAY_POINTER, &ptr);
            desc.m_pointer = reinterpret_cast<vogl_trace_ptr_value>(ptr);

            VOGL_CHECK_GL_ERROR;
        }
    }

    m_is_valid = true;

    return true;
}
开发者ID:Cyberbanan,项目名称:vogl,代码行数:54,代码来源:vogl_vao_state.cpp

示例2:

vogleditor_stateTreeVertexArrayItem::vogleditor_stateTreeVertexArrayItem(QString name, QString value, GLuint64 handle, vogleditor_stateTreeItem* parent, vogl_vao_state& state, const vogl_context_info& info)
    : vogleditor_stateTreeItem(name, value, parent),
      m_pState(&state),
      m_handle(handle),
      m_pDiffBaseState(NULL)
{
    static QString tmp;
    for (uint i = 0; i < info.get_max_vertex_attribs(); i++)
    {
       vogleditor_stateTreeItem* pAttribNode = new vogleditor_stateTreeItem(tmp.sprintf("GL_VERTEX_ATTRIB %u", i), "", this);
       this->appendChild(pAttribNode);

       const vogl_vertex_attrib_desc& desc = state.get_vertex_attrib_desc(i);

       // Peter: FIXME, this is now vao state
       //{ vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_ELEMENT_ARRAY_BUFFER_BINDING", &vogl_vertex_attrib_desc::m_element_array_binding, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING", &vogl_vertex_attrib_desc::m_array_binding, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_ENABLED", &vogl_vertex_attrib_desc::m_enabled, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayIntItem* pItem = new vogleditor_stateTreeVertexArrayIntItem("GL_VERTEX_ATTRIB_ARRAY_SIZE", &vogl_vertex_attrib_desc::m_size, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayEnumItem* pItem = new vogleditor_stateTreeVertexArrayEnumItem("GL_VERTEX_ATTRIB_ARRAY_TYPE", &vogl_vertex_attrib_desc::m_type, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_NORMALIZED", &vogl_vertex_attrib_desc::m_normalized, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayIntItem* pItem = new vogleditor_stateTreeVertexArrayIntItem("GL_VERTEX_ATTRIB_ARRAY_STRIDE", &vogl_vertex_attrib_desc::m_stride, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayBoolItem* pItem = new vogleditor_stateTreeVertexArrayBoolItem("GL_VERTEX_ATTRIB_ARRAY_INTEGER", &vogl_vertex_attrib_desc::m_integer, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayUIntItem* pItem = new vogleditor_stateTreeVertexArrayUIntItem("GL_VERTEX_ATTRIB_ARRAY_DIVISOR", &vogl_vertex_attrib_desc::m_divisor, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
       { vogleditor_stateTreeVertexArrayPtrItem* pItem = new vogleditor_stateTreeVertexArrayPtrItem("GL_VERTEX_ATTRIB_ARRAY_POINTER", &vogl_vertex_attrib_desc::m_pointer, pAttribNode, desc, i); m_diffableItems.push_back(pItem); pAttribNode->appendChild(pItem); }
    }
}
开发者ID:Nicky-D,项目名称:vogl,代码行数:27,代码来源:vogleditor_statetreevertexarrayitem.cpp

示例3: restore

bool vogl_vao_state::restore(const vogl_context_info &context_info, vogl_handle_remapper &remapper, GLuint64 &handle) const
{
    VOGL_FUNC_TRACER

    VOGL_CHECK_GL_ERROR;

    if (!m_is_valid)
        return false;

    vogl_scoped_binding_state orig_binding(GL_VERTEX_ARRAY, GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER);

    if ((!m_snapshot_handle) && (!handle))
    {
        GL_ENTRYPOINT(glBindVertexArray)(0);
        VOGL_CHECK_GL_ERROR;
    }
    else
    {
        if (!handle)
        {
            GLuint handle32 = 0;
            GL_ENTRYPOINT(glGenVertexArrays)(1, &handle32);
            if ((vogl_check_gl_error()) || (!handle32))
                return false;
            handle = handle32;

            if (m_snapshot_handle)
            {
                remapper.declare_handle(VOGL_NAMESPACE_VERTEX_ARRAYS, m_snapshot_handle, handle, GL_NONE);
                VOGL_ASSERT(remapper.remap_handle(VOGL_NAMESPACE_VERTEX_ARRAYS, m_snapshot_handle) == handle);
            }
        }

        if (m_has_been_bound)
        {
            GL_ENTRYPOINT(glBindVertexArray)(static_cast<GLuint>(handle));
            VOGL_CHECK_GL_ERROR;
        }
    }

    if (m_has_been_bound)
    {
        GL_ENTRYPOINT(glBindBuffer)(GL_ELEMENT_ARRAY_BUFFER, static_cast<GLuint>(remapper.remap_handle(VOGL_NAMESPACE_BUFFERS, m_element_array_binding)));
        VOGL_CHECK_GL_ERROR;

        if (m_vertex_attribs.size() > context_info.get_max_vertex_attribs())
        {
            vogl_warning_printf("Saved VAO state has %u attribs, but context only allows %u attribs\n", m_vertex_attribs.size(), context_info.get_max_vertex_attribs());
        }

        for (uint32_t i = 0; i < math::minimum<uint32_t>(context_info.get_max_vertex_attribs(), m_vertex_attribs.size()); i++)
        {
            const vogl_vertex_attrib_desc &desc = m_vertex_attribs[i];

            GL_ENTRYPOINT(glBindBuffer)(GL_ARRAY_BUFFER, static_cast<GLuint>(remapper.remap_handle(VOGL_NAMESPACE_BUFFERS, desc.m_array_binding)));
            VOGL_CHECK_GL_ERROR;

            vogl_trace_ptr_value trace_ptr_val = desc.m_pointer;

            vogl_trace_ptr_value restore_ptr_val = trace_ptr_val;
            if ((!desc.m_array_binding) && (trace_ptr_val) && (context_info.is_compatibility_profile()))
                restore_ptr_val = remapper.remap_vertex_attrib_ptr(i, trace_ptr_val);

            void *pRestore_ptr = reinterpret_cast<void *>(restore_ptr_val);

            if ((handle) && (desc.m_array_binding == 0))
            {
                // If it's a non-default VAO, and there's no array binding, we can't call glVertexAttribPointer() because it's not allowed by AMD drivers (it thinks we're trying to set client side array data)
                // "OpenGL: glVertexAttribPointer failed because it is not allowed to specify a client-side vertex or element array when a non-default vertex array object is bound (GL_INVALID_OPERATION) [source=API type=ERROR severity=HIGH id=2100]"

                // Sanity checks.
                if ((pRestore_ptr != NULL) || (desc.m_stride) || (desc.m_enabled))
                {
                    vogl_warning_printf("Can't bind client side vertex array data on a non-default VAO, trace handle %u GL handle %u, restore ptr %p, size %i stride %i enabled %u\n",
                                        m_snapshot_handle, static_cast<uint32_t>(handle), pRestore_ptr, desc.m_size, desc.m_stride, desc.m_enabled);
                }
            }
            else
            {
                if (desc.m_integer)
                {
                    GL_ENTRYPOINT(glVertexAttribIPointer)(i, desc.m_size, desc.m_type, desc.m_stride, pRestore_ptr);
                    VOGL_CHECK_GL_ERROR;
                }
                else
                {
                    GL_ENTRYPOINT(glVertexAttribPointer)(i, desc.m_size, desc.m_type, desc.m_normalized, desc.m_stride, pRestore_ptr);
                    VOGL_CHECK_GL_ERROR;
                }
            }

            GL_ENTRYPOINT(glVertexAttribDivisor)(i, desc.m_divisor);
            VOGL_CHECK_GL_ERROR;

            if (desc.m_enabled)
            {
                GL_ENTRYPOINT(glEnableVertexAttribArray)(i);
                VOGL_CHECK_GL_ERROR;
            }
            else
//.........这里部分代码省略.........
开发者ID:Cyberbanan,项目名称:vogl,代码行数:101,代码来源:vogl_vao_state.cpp


注:本文中的vogl_context_info::get_max_vertex_attribs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。