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


C++ GLWindow::swapBuffers方法代码示例

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


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

示例1: swapBuffers

 void GLFrameBuffer::swapBuffers() {
     if(!mOffscreen) {
         GLWindow* window = checked_cast<GLWindow*>(Context::Instance().getApp().getWindowPtr().get());
         if(window)
             window->swapBuffers();
     }
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例2: main

int main(int argc, char** argv) {
    auto glversion = gl::getAvailableVersion();
    auto major = GL_GET_MAJOR_VERSION(glversion);
    auto minor = GL_GET_MINOR_VERSION(glversion);

    if (glversion < GL_MAKE_VERSION(4, 1)) {
        MessageBoxA(nullptr, "Interface requires OpenGL 4.1 or higher", "Unsupported", MB_OK);
        return 0;
    }
    QGuiApplication app(argc, argv);

    bool quitting = false;
    // FIXME need to handle window closing message so that we can stop the timer
    GLWindow* window = new GLWindow();
    window->create();
    window->show();
    window->setSurfaceType(QSurface::OpenGLSurface);
    window->setFormat(getDefaultOpenGLSurfaceFormat());
    bool contextCreated = false;
    QTimer* timer = new QTimer();
    QObject::connect(timer, &QTimer::timeout, [&] {
        if (quitting) {
            return;
        }
        if (!contextCreated) {
            window->createContext();
            contextCreated = true;
        }
        if (!window->makeCurrent()) {
            throw std::runtime_error("Failed");
        }
        glClearColor(1.0f, 0.0f, 1.0f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);
        window->swapBuffers();
        window->doneCurrent();
    });
    // FIXME need to handle window closing message so that we can stop the timer
    QObject::connect(&app, &QCoreApplication::aboutToQuit, [&] {
        quitting = true;
        QObject::disconnect(timer, &QTimer::timeout, nullptr, nullptr);
        timer->stop();
        timer->deleteLater();
    });

    timer->setInterval(15);
    timer->setSingleShot(false);
    timer->start();
    app.exec();
    return 0;
}
开发者ID:Atlante45,项目名称:hifi,代码行数:50,代码来源:main.cpp

示例3: threadLoop


//.........这里部分代码省略.........
            pEngine = new GLDOPPColorInvert;
            break;

        case EDGE_FILTER:
            pEngine = new GLDOPPEdgeFilter;
            break;

        case DISTORT_EFFECT:
            pEngine = new GLDOPPDistort;
            break;

        case ROTATE_DESKTOP:
            pEngine = new GLDOPPRotate;
            break;

        default:
            pEngine = new GLDOPPEngine;
            break;
    }

    // m_uiDesktopSelection is the id of the selected element in the Combo Box
    // Need to add 1 to get the desktop id as shown in CCC
    if (!pEngine->initDOPP(m_uiDesktopSelection + 1))
    {
        // prevent thread loop to start due to error
        m_bEngineRunning = false;
    }



    if (!pEngine->initEffect())
    {
        // prevent thread loop to start due to error
        m_bEngineRunning = false;
    }


	if (m_bEngineRunning && m_uiEffectSelection == ROTATE_DESKTOP)
    {
        GLDOPPRotate* pRot = dynamic_cast<GLDOPPRotate*>(pEngine);
        pRot->setRotation((float)m_uiRotationAngle);
    }



    if (bCapture && m_bEngineRunning)
    {
        // Open window only if this option was checked in the GUI
        pWin->open();
    }

    // Enable SW mouse
    SystemParametersInfo(SPI_SETMOUSETRAILS, 2, 0, 0);

    MSG mMsg;

    while(m_bEngineRunning)
    {
        pEngine->processDesktop();
        
        if (bCapture)
        {
            // Blit FBO of DOPPEngine into the window
            glViewport(0, 0, g_uiWindowWidth, g_uiWindowHeight);

            glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
            glBindFramebuffer(GL_READ_FRAMEBUFFER, pEngine->getPresentBuffer());

            glBlitFramebuffer(0, pEngine->getDesktopHeight(), pEngine->getDesktopWidth(), 0, 0, 0, g_uiWindowWidth, g_uiWindowHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);

            glBindFramebuffer(GL_FRAMEBUFFER, 0);

            pWin->swapBuffers();

            if (PeekMessage(&mMsg, NULL, 0, 0, PM_REMOVE))
		    {
			    if (mMsg.message == WM_QUIT)
			    {
				    m_bEngineRunning = false;
			    }
                else
			    {
				    TranslateMessage(&mMsg);
				    DispatchMessage(&mMsg);
			    }
		    }
        }
    } 

    // Disable SW mouse
    SystemParametersInfo(SPI_SETMOUSETRAILS, 1, 0, 0);

    delete pEngine;

    delete pWin;

    ::UnregisterClass(cClassName, NULL);

    return 0;
}
开发者ID:GPUOpen-LibrariesAndSDKs,项目名称:DOPP,代码行数:101,代码来源:DOPPEngineDlg.cpp


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