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


C++ ContextFormat::colorBits方法代码示例

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


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

示例1: while

static already_AddRefed<GLContextWGL>
CreatePBufferOffscreenContext(const gfxIntSize& aSize,
                              const ContextFormat& aFormat)
{
#define A1(_a,_x)  do { _a.AppendElement(_x); } while(0)
#define A2(_a,_x,_y)  do { _a.AppendElement(_x); _a.AppendElement(_y); } while(0)

    nsTArray<int> attrs;

    A2(attrs, LOCAL_WGL_SUPPORT_OPENGL_ARB, LOCAL_GL_TRUE);
    A2(attrs, LOCAL_WGL_DRAW_TO_PBUFFER_ARB, LOCAL_GL_TRUE);
    A2(attrs, LOCAL_WGL_DOUBLE_BUFFER_ARB, LOCAL_GL_FALSE);

    A2(attrs, LOCAL_WGL_ACCELERATION_ARB, LOCAL_WGL_FULL_ACCELERATION_ARB);

    A2(attrs, LOCAL_WGL_COLOR_BITS_ARB, aFormat.colorBits());
    A2(attrs, LOCAL_WGL_RED_BITS_ARB, aFormat.red);
    A2(attrs, LOCAL_WGL_GREEN_BITS_ARB, aFormat.green);
    A2(attrs, LOCAL_WGL_BLUE_BITS_ARB, aFormat.blue);
    A2(attrs, LOCAL_WGL_ALPHA_BITS_ARB, aFormat.alpha);

    A2(attrs, LOCAL_WGL_DEPTH_BITS_ARB, aFormat.depth);
    A2(attrs, LOCAL_WGL_STENCIL_BITS_ARB, aFormat.stencil);

    if (aFormat.alpha > 0) {
        A2(attrs, LOCAL_WGL_BIND_TO_TEXTURE_RGBA_ARB, LOCAL_GL_TRUE);
    } else {
        A2(attrs, LOCAL_WGL_BIND_TO_TEXTURE_RGB_ARB, LOCAL_GL_TRUE);
    }

    A2(attrs, LOCAL_WGL_DOUBLE_BUFFER_ARB, LOCAL_GL_FALSE);
    A2(attrs, LOCAL_WGL_STEREO_ARB, LOCAL_GL_FALSE);

    A1(attrs, 0);

    nsTArray<int> pbattrs;
    A2(pbattrs, LOCAL_WGL_TEXTURE_TARGET_ARB, LOCAL_WGL_TEXTURE_2D_ARB);

    if (aFormat.alpha > 0) {
        A2(pbattrs, LOCAL_WGL_TEXTURE_FORMAT_ARB, LOCAL_WGL_TEXTURE_RGBA_ARB);
    } else {
        A2(pbattrs, LOCAL_WGL_TEXTURE_FORMAT_ARB, LOCAL_WGL_TEXTURE_RGB_ARB);
    }
    A1(pbattrs, 0);

    UINT numFormats = 256;
    int formats[256];

    if (!sWGLLibrary.fChoosePixelFormat(gSharedWindowDC,
                                        attrs.Elements(), NULL,
                                        numFormats, formats, &numFormats)
        || numFormats == 0)
    {
        return nsnull;
    }

    // XXX add back the priority choosing code here
    int chosenFormat = formats[0];

    if (!IsValidSizeForFormat(gSharedWindowDC, chosenFormat, aSize))
        return nsnull;

    HANDLE pbuffer = sWGLLibrary.fCreatePbuffer(gSharedWindowDC, chosenFormat,
                                                aSize.width, aSize.height,
                                                pbattrs.Elements());
    if (!pbuffer) {
        return nsnull;
    }

    HDC pbdc = sWGLLibrary.fGetPbufferDC(pbuffer);
    NS_ASSERTION(pbdc, "expected a dc");

    HGLRC context;
    if (sWGLLibrary.HasRobustness()) {
        int attribs[] = {
            LOCAL_WGL_CONTEXT_FLAGS_ARB, LOCAL_WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB,
            LOCAL_WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, LOCAL_WGL_LOSE_CONTEXT_ON_RESET_ARB,
            NULL
        };

        context = sWGLLibrary.fCreateContextAttribs(pbdc, nsnull, attribs);
    } else {
        context = sWGLLibrary.fCreateContext(pbdc);
    }

    if (!context) {
        sWGLLibrary.fDestroyPbuffer(pbuffer);
        return false;
    }

    nsRefPtr<GLContextWGL> glContext = new GLContextWGL(aFormat,
                                                        nsnull,
                                                        pbuffer,
                                                        pbdc,
                                                        context,
                                                        chosenFormat);

    return glContext.forget();
}
开发者ID:eric30,项目名称:mozilla-central,代码行数:99,代码来源:GLContextProviderWGL.cpp


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