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


C++ GLContext::activate方法代码示例

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


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

示例1: renderWindow

void Canvas::renderWindow(WindowPtr pWindow, MCFBOPtr pFBO, const IntRect& viewport)
{
    GLContext* pContext = pWindow->getGLContext();
    pContext->activate();

    GLContextManager::get()->uploadDataForContext();
    renderFX(pContext);
    glm::mat4 projMat;
    if (pFBO) {
        pFBO->activate(pContext);
        glm::vec2 size = m_pRootNode->getSize();
        projMat = glm::ortho(0.f, size.x, 0.f, size.y);
        glViewport(0, 0, GLsizei(size.x), GLsizei(size.y));
    } else {
        glproc::BindFramebuffer(GL_FRAMEBUFFER, 0);
        projMat = glm::ortho(float(viewport.tl.x), float(viewport.br.x), 
                float(viewport.br.y), float(viewport.tl.y));
        IntPoint windowSize = pWindow->getSize();
        glViewport(0, 0, windowSize.x, windowSize.y);
    }
    {
        ScopeTimer Timer(VATransferProfilingZone);
        m_pVertexArray->update(pContext);
    }
    clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT,
            !pFBO);
    GLContext::checkError("Canvas::renderWindow: glViewport()");
    m_pVertexArray->activate(pContext);
    {
        ScopeTimer timer(RootRenderProfilingZone);
        m_pRootNode->maybeRender(pContext, projMat);
    }
    renderOutlines(pContext, projMat);
}
开发者ID:eladm29,项目名称:libavg,代码行数:34,代码来源:Canvas.cpp

示例2: getFrameFromPBO

void VideoWriter::getFrameFromPBO()
{
    if (m_bFramePending) {
        BitmapPtr pBmp;
        GLContext* pOldContext = GLContext::getCurrent();
        m_pMainGLContext->activate();
        if (m_pFilter) {
            pBmp = m_pFilter->getFBO(m_pMainGLContext)->getImageFromPBO();
        } else {
            pBmp = m_pFBO->getImageFromPBO();
        }
            pOldContext->activate();
        sendFrameToEncoder(pBmp);
        m_bFramePending = false;
    }
}
开发者ID:bluscr33n,项目名称:libavg,代码行数:16,代码来源:VideoWriter.cpp

示例3: windowDimensions

SecondaryWindow::SecondaryWindow(const WindowParams& wp, bool bIsFullscreen,
        GLConfig glConfig)
    : Window(wp, bIsFullscreen)
{
#ifdef linux
    GLContext* pMainContext = GLContext::getCurrent();
    GLContext* pGLContext;
    IntRect windowDimensions(wp.m_Pos, wp.m_Pos+wp.m_Size);
    string sDisplay = ":0." + toString(wp.m_DisplayServer);
    pGLContext = new SecondaryGLXContext(glConfig, sDisplay, windowDimensions,
            wp.m_bHasWindowFrame);
    setGLContext(pGLContext);
    
    pMainContext->activate();
#endif
}
开发者ID:JohnChu,项目名称:libavg,代码行数:16,代码来源:SecondaryWindow.cpp

示例4: getFrameFromFBO

void VideoWriter::getFrameFromFBO()
{
    if (m_pFBO) {
        GLContext* pOldContext = GLContext::getCurrent();
        m_pMainGLContext->activate();
        if (m_pFilter) {
            m_pFilter->apply(m_pMainGLContext, m_pFBO->getTex());
            FBOPtr pYUVFBO = m_pFilter->getFBO(m_pMainGLContext);
            pYUVFBO->moveToPBO();
        } else {
            m_pFBO->moveToPBO();
        }
        pOldContext->activate();
        m_bFramePending = true;
    } else {
        BitmapPtr pBmp = Player::get()->getDisplayEngine()->screenshot(GL_BACK);
        sendFrameToEncoder(pBmp);
    }
}
开发者ID:bluscr33n,项目名称:libavg,代码行数:19,代码来源:VideoWriter.cpp

示例5: onFrameEnd

void VideoWriter::onFrameEnd()
{
    // The VideoWriter handles OffscreenCanvas and MainCanvas differently:
    // For MainCanvas, it simply does a screenshot onFrameEnd and sends that to the 
    // VideoWriterThread immediately.
    // For OffscreenCanvas, an asynchronous PBO readback is started in onFrameEnd.
    // In the next frame's onFrameEnd, the data is read into a bitmap and sent to 
    // the VideoWriterThread.
    if (m_pFBO) {
        // Read last frame's bitmap.
        GLContext* pOldContext = GLContext::getCurrent();
        m_pMainGLContext->activate();
        getFrameFromPBO();
        pOldContext->activate();
    }
    if (m_StartTime == -1) {
        m_StartTime = Player::get()->getFrameTime();
    }
    if (!m_bPaused) {
        if (m_bSyncToPlayback) {
            getFrameFromFBO();
        } else {
            long long movieTime = Player::get()->getFrameTime() - m_StartTime
                    - m_PauseTime;
            float timePerFrame = 1000.f/m_FrameRate;
            int wantedFrame = int(movieTime/timePerFrame+0.1);
            if (wantedFrame > m_CurFrame) {
                getFrameFromFBO();
                if (wantedFrame > m_CurFrame + 1) {
                    m_CurFrame = wantedFrame - 1;
                }
            }
        }
    }
    
    if (!m_pFBO) {
        getFrameFromPBO();
    }
}
开发者ID:bluscr33n,项目名称:libavg,代码行数:39,代码来源:VideoWriter.cpp

示例6: Exception

VideoWriter::VideoWriter(CanvasPtr pCanvas, const string& sOutFileName, int frameRate,
        int qMin, int qMax, bool bSyncToPlayback)
    : m_pCanvas(pCanvas),
      m_sOutFileName(sOutFileName),
      m_FrameRate(frameRate),
      m_QMin(qMin),
      m_QMax(qMax),
      m_bHasValidData(false),
      m_bSyncToPlayback(bSyncToPlayback),
      m_bPaused(false),
      m_PauseTime(0),
      m_bStopped(false),
      m_CurFrame(0),
      m_StartTime(-1),
      m_bFramePending(false)
{
    if (!pCanvas) {
        throw Exception(AVG_ERR_INVALID_ARGS, "VideoWriter needs a canvas to write to.");
    }
    if (GLContext::getCurrent()->isGLES()) {
        throw Exception(AVG_ERR_UNSUPPORTED, "VideoWriter not supported under GLES.");
    }
#ifdef WIN32
    int fd = _open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, _S_IREAD | _S_IWRITE);
#elif defined __linux__
    int fd = open64(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#else
    int fd = open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
#endif
    if (fd == -1) {
        throw Exception(AVG_ERR_VIDEO_INIT_FAILED, 
                string("Could not open output file '") + m_sOutFileName + "'. Reason: " +
                strerror(errno));
    }
#ifdef WIN32
    _close(fd);
#else
    close(fd);
#endif
    remove(m_sOutFileName.c_str());
    CanvasPtr pMainCanvas = Player::get()->getMainCanvas();
    DisplayEngine* pDisplayEngine = Player::get()->getDisplayEngine();
    if (pMainCanvas == m_pCanvas) {
        m_FrameSize = pDisplayEngine->getWindowSize();
    } else {
        m_FrameSize = m_pCanvas->getSize();
        GLContext* pOldContext = GLContext::getCurrent();
        m_pMainGLContext = pDisplayEngine->getWindow(0)->getGLContext();
        m_pMainGLContext->activate();
        m_pFBO = dynamic_pointer_cast<OffscreenCanvas>(m_pCanvas)->
                getFBO(m_pMainGLContext);
        if (GLContext::getCurrent()->useGPUYUVConversion()) {
            m_pFilter = GPURGB2YUVFilterPtr(new GPURGB2YUVFilter(m_FrameSize));
        }
        pOldContext->activate();
    }
    VideoWriterThread writer(m_CmdQueue, m_sOutFileName, m_FrameSize, m_FrameRate, 
            qMin, qMax);
    m_pThread = new boost::thread(writer);
    m_pCanvas->registerPlaybackEndListener(this);
    m_pCanvas->registerFrameEndListener(this);
}
开发者ID:bluscr33n,项目名称:libavg,代码行数:62,代码来源:VideoWriter.cpp


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