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


C++ Contexts::find方法代码示例

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


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

示例1: wglMakeCurrent

WINGDIAPI BOOL WINAPI wglMakeCurrent(HDC hdc, DHGLRC hglrc)
{
    if (!gCurrentContextSet)
    {
        gCurrentContext = gContexts.end();
        gCurrentContextSet = true;
    }

    if (!hdc || !hglrc)
    {
        gCurrentContext = gContexts.end();
        return 1;
    }

    int rc = (int)hglrc;

    if (gContexts.find(rc) == gCurrentContext)
    {
        return 1;
    }

    gCurrentContext = gContexts.find(rc);

    auto &xCtxt = gContexts[rc];
    OGL::State *pState = xCtxt.pState;

    HWND hWnd = WindowFromDC(hdc);
    RECT rect;
    GetClientRect(hWnd, &rect);

    int width = rect.right - rect.left;
    int height = rect.bottom - rect.top;

    SetOGL(pState);
    OGL::GetDDProcTable().pfnBindContext(OGL::GetDDHandle(), NULL, hWnd, NULL, width, height);

    // according to spec, only set current viewport to draw buffer dimensions if the context hasn't
    // been initialized
    if (!xCtxt.initialized)
    {
        pState->mViewport.x = 0;
        pState->mViewport.y = 0;
        pState->mViewport.width = width;
        pState->mViewport.height = height;
        pState->mScissor.x = 0;
        pState->mScissor.y = 0;
        pState->mScissor.width = width;
        pState->mScissor.height = height;
        xCtxt.initialized = true;
    }
    return 1;
}
开发者ID:prabindh,项目名称:openswr,代码行数:52,代码来源:wgl.cpp

示例2: glXDestroyContext

void glXDestroyContext(Display *pDisplay, GLXContext ctx)
{
    auto *pState = reinterpret_cast<OGL::State *>(ctx);

    if (contexts.find(pState) == currentContext)
    {
        currentContext = contexts.end();
    }

    contexts.erase(pState);

    OGL::Destroy(*pState);
    pState->~State();

    _aligned_free(pState);
}
开发者ID:NoSuchProcess,项目名称:openswr,代码行数:16,代码来源:glx.cpp

示例3: glXMakeContextCurrent

Bool glXMakeContextCurrent(Display *pDisplay, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
{
    // unbind current context if NULL ctx passed in
    if (ctx == NULL)
    {
        currentContext = contexts.end();
        return 1;
    }

    auto *pState = reinterpret_cast<OGL::State *>(ctx);
    if (contexts.find(pState) == currentContext)
    {
        return 1;
    }

    auto &xCtxt = contexts[pState];
    xCtxt.drawable = draw;

    SetOGL(pState);

    GLuint width, height;
    XWindowAttributes xWindowAttributes = { 0 };
    SWRPBuffer *buf;
    bool isDisplay;
    switch (gDrawables[draw])
    {
    case X:
        XGetWindowAttributes(pDisplay, draw, &xWindowAttributes);
        width = xWindowAttributes.width;
        height = xWindowAttributes.height;
        isDisplay = true;
        break;
    case PBUFFER:
        buf = (SWRPBuffer *)draw;
        width = buf->width;
        height = buf->height;
        isDisplay = false;
        break;
    default:
        assert(0 && "Invalid buffer type");
        return 0;
    }

    // bind render target set to SWR pipeline
    FrameBuffer *fb;
    if (gDrawableBuffers.find(draw) == gDrawableBuffers.end())
    {
        // we haven't seen this drawable yet, create a new frame buffer
        fb = new FrameBuffer();
        fb->Initialize(width, height, draw, xCtxt.pDisplay, xCtxt.pVisInfo, isDisplay);
        gDrawableBuffers[draw] = fb;
    }
    else
    {
        fb = gDrawableBuffers[draw];
    }

    OGL::GetDDProcTable().pfnSetRenderTarget(OGL::GetDDHandle(), fb->GetBackBuffer(), fb->GetDepthBuffer());

    // according to spec, only set current viewport to draw buffer dimensions if the context hasn't
    // been initialized
    if (!xCtxt.initialized)
    {
        pState->mViewport.x = 0;
        pState->mViewport.y = 0;
        pState->mViewport.width = width;
        pState->mViewport.height = height;
        pState->mScissor.x = 0;
        pState->mScissor.y = 0;
        pState->mScissor.width = width;
        pState->mScissor.height = height;
        xCtxt.initialized = true;
    }

    currentContext = contexts.find(pState);

    return 1;
}
开发者ID:NoSuchProcess,项目名称:openswr,代码行数:78,代码来源:glx.cpp


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