예제 #1
0
/////////////////////////////////////////////////////////////////////////
// Main initialization point
//
int sample_main(int argc, const char** argv)
{
    NVPWindow::ContextFlags context(
    3,      //major;
    3,      //minor;
    false,   //core;
    1,      //MSAA;
    true,   //debug;
    false,  //robust;
    false,  //forward;
    NULL   //share;
    );

    g_myWindow.argc = argc;
    g_myWindow.argv = argv;

    if(!g_myWindow.create("bk3d viewer", &context))
        return false;

    g_myWindow.makeContextCurrent();
    g_myWindow.swapInterval(0);

    while(MyWindow::sysPollEvents(false) )
    {
        idle();
    }
    return true;
}
//------------------------------------------------------------------------------
// 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;
}