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


C++ Extensions3D::framebufferTexture2DMultisampleIMG方法代码示例

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


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

示例1: getExtensions

bool GraphicsContext3D::reshapeFBOs(const IntSize& size)
{
    // A BlackBerry-specific implementation of reshapeFBOs is necessary because it contains:
    //  - an Imagination-specific implementation of anti-aliasing
    //  - an Imagination-specific fix for FBOs of size less than (16,16)

    int fboWidth = size.width();
    int fboHeight = size.height();

    // Imagination-specific fix
    if (m_isImaginationHardware) {
        fboWidth = std::max(fboWidth, 16);
        fboHeight = std::max(fboHeight, 16);
    }

    GLuint internalColorFormat, colorFormat, internalDepthStencilFormat = 0;
    if (m_attrs.alpha) {
        internalColorFormat = GL_RGBA;
        colorFormat = GL_RGBA;
    } else {
        internalColorFormat = GL_RGB;
        colorFormat = GL_RGB;
    }
    if (m_attrs.stencil || m_attrs.depth) {
        // We don't allow the logic where stencil is required and depth is not.
        // See GraphicsContext3D constructor.
        if (m_attrs.stencil && m_attrs.depth)
            internalDepthStencilFormat = GL_DEPTH24_STENCIL8_EXT;
        else
            internalDepthStencilFormat = GL_DEPTH_COMPONENT16;
    }

    GLint sampleCount = 8;
    if (m_attrs.antialias) {
        GLint maxSampleCount;
        // Hardcode the maximum number of samples due to header issue (PR132183)
        // ::glGetIntegerv(GL_MAX_SAMPLES_IMG, &maxSampleCount);
        maxSampleCount = 4;
        sampleCount = std::min(8, maxSampleCount);
    }

    bool mustRestoreFBO = false;
    if (m_state.boundFBO != m_fbo) {
        mustRestoreFBO = true;
        ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_fbo);
    }

    ::glBindTexture(GL_TEXTURE_2D, m_texture);
    ::glTexImage2D(GL_TEXTURE_2D, 0, internalColorFormat, fboWidth, fboHeight, 0, colorFormat, GL_UNSIGNED_BYTE, 0);

    Extensions3D* extensions = getExtensions();
    if (m_attrs.antialias) {
        extensions->framebufferTexture2DMultisampleIMG(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0, sampleCount);

        if (m_attrs.stencil || m_attrs.depth) {
            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            extensions->renderbufferStorageMultisampleIMG(GL_RENDERBUFFER_EXT, sampleCount, internalDepthStencilFormat, fboWidth, fboHeight);

            if (m_attrs.stencil)
                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            if (m_attrs.depth)
                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
        }
    } else {
        ::glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, m_texture, 0);

        if (m_attrs.stencil || m_attrs.depth) {
            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            ::glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, internalDepthStencilFormat, fboWidth, fboHeight);

            if (m_attrs.stencil)
                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            if (m_attrs.depth)
                ::glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, m_depthStencilBuffer);
            ::glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
        }
    }
    ::glBindTexture(GL_TEXTURE_2D, 0);


    logFrameBufferStatus(__LINE__);

    return mustRestoreFBO;
}
开发者ID:Zangalot,项目名称:phantomjs-webkit,代码行数:85,代码来源:GraphicsContext3DBlackBerry.cpp


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