コード例 #1
0
        void ComboSelectionChanged(IControlCombo *pWin, unsigned int selectedidx)
            {   
                if(!strcmp(pWin->GetID(), "RENDER"))
                {
                    MyWindow* p = reinterpret_cast<MyWindow*>(pWin->GetUserData());
                    s_pCurRenderer->terminateGraphics();
                    s_pCurRenderer = g_renderers[selectedidx];
                    s_curRenderer = selectedidx;
                    s_pCurRenderer->initGraphics(p->m_winSz[0], p->m_winSz[1], g_Supersampling, g_MSAA);
                    g_profiler.setDefaultGPUInterface(s_pCurRenderer->getTimerInterface());
                    s_pCurRenderer->setDownSamplingMode(g_downSamplingMode);
                    p->reshape(p->m_winSz[0], p->m_winSz[1]);
                }
                else if(!strcmp(pWin->GetID(), "DS"))
                {
                    g_downSamplingMode = pWin->GetItemData(selectedidx);
                    s_pCurRenderer->setDownSamplingMode( g_downSamplingMode );
                }
                else if(!strcmp(pWin->GetID(), "SS"))
                {
                    g_Supersampling = 0.1f * (float)pWin->GetItemData(selectedidx);
                    MyWindow* p = reinterpret_cast<MyWindow*>(pWin->GetUserData());
                    //
                    // update the token buffer in which the viewport setup happens for token rendering
                    //
					s_pCurRenderer->updateViewport(0, 0, p->getWidth(), p->getHeight(), g_Supersampling);
                }
                else if(!strcmp(pWin->GetID(), "MSAA"))
                {
                    g_MSAA = pWin->GetItemData(selectedidx);
                    // involves some changes at the source of initialization... re-create all
                    MyWindow* p = reinterpret_cast<MyWindow*>(pWin->GetUserData());
                    g_profiler.reset(1);
                    s_pCurRenderer->terminateGraphics();
                    s_pCurRenderer->initGraphics(p->m_winSz[0], p->m_winSz[1], g_Supersampling, g_MSAA);
                }
            }
コード例 #2
0
//------------------------------------------------------------------------------
// Main initialization point
//------------------------------------------------------------------------------
int sample_main(int argc, const char** argv)
{
    // you can create more than only one
    static MyWindow myWindow;
    // -------------------------------
    // Basic OpenGL settings
    //
    NVPWindow::ContextFlags context(
    4,      //major;
    3,      //minor;
    false,   //core;
    1,      //MSAA;
    24,     //depth bits
    8,      //stencil bits
    false,   //debug;
    false,  //robust;
    false,  //forward;
    NULL   //share;
    );

    // -------------------------------
    // Create the window
    //
    if(!myWindow.create("gl_vk_supersampled", &context, 1280,720))
    {
        LOGE("Failed to initialize the sample\n");
        return false;
    }

    // -------------------------------
    // Parse arguments/options
    //
    for(int i=1; i<argc; i++)
    {
        if(strlen(argv[i]) <= 1)
            continue;
        switch(argv[i][1])
        {
        case 's':
            s_bStats = atoi(argv[++i]) ? true : false;
            LOGI("s_bStats set to %s\n", s_bStats ? "true":"false");
            break;
        case 'q':
            g_MSAA = atoi(argv[++i]);
            #ifdef USESVCUI
            if(g_pWinHandler) g_pWinHandler->GetCombo("MSAA")->SetSelectedByData(g_MSAA);
            #endif
            LOGI("g_MSAA set to %d\n", g_MSAA);
            break;
        case 'r':
            g_Supersampling = atof(argv[++i]);
            #ifdef USESVCUI
            if(g_pWinHandler) g_pWinHandler->GetCombo("SS")->SetSelectedByData(g_Supersampling*10);
            #endif
            LOGI("g_Supersampling set to %.2f\n", g_Supersampling);
            break;
        case 'd':
            #ifdef USESVCUI
            if(g_pTweakContainer) g_pTweakContainer->SetVisible(atoi(argv[++i]) ? 1 : 0);
            #endif
            break;
        default:
            LOGE("Wrong command-line\n");
        case 'h':
            LOGI(s_sampleHelpCmdLine);
            break;
        }
    }
	s_pCurRenderer = g_renderers[s_curRenderer];
	s_pCurRenderer->initGraphics(myWindow.getWidth(), myWindow.getHeight(), g_Supersampling, g_MSAA);
    g_profiler.init();
    g_profiler.setDefaultGPUInterface(s_pCurRenderer->getTimerInterface());
    s_pCurRenderer->setDownSamplingMode(g_downSamplingMode);

    // -------------------------------
    // Message pump loop
    //
    myWindow.makeContextCurrent();
    myWindow.swapInterval(0);
    myWindow.reshape();

    while(MyWindow::sysPollEvents(false) )
    {
        myWindow.idle();
    }
    return true;
}