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


C++ System::setCallback方法代码示例

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


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

示例1: FMOD_Main

int FMOD_Main()
{
    void *extraDriverData = 0;
    Common_Init(&extraDriverData);

    RunData data;
    Common_Mutex_Create(&data.criticalSection);

    FMOD::Studio::System* system;
    ERRCHECK( FMOD::Studio::System::create(&system) );
    FMOD::System* lowLevelSystem;
    ERRCHECK( system->getLowLevelSystem(&lowLevelSystem) );
    ERRCHECK( lowLevelSystem->setCallback(SystemCallback) );
    ERRCHECK( lowLevelSystem->setUserData(&data) );

    ERRCHECK( system->initialize(32, FMOD_STUDIO_INIT_NORMAL, FMOD_INIT_NORMAL, extraDriverData) );

    for (int i=0; i<BANK_COUNT; ++i)
    {
        data.banks[i] = NULL;
    }

    bool wantSampleLoad = false;

    do
    {
        Common_Update();
        
        if (Common_BtnPress(BTN_ACTION1))
        {
            // Start loading all the banks
            for (int i=0; i<BANK_COUNT; ++i)
            {
                if (data.banks[i] == NULL || !data.banks[i]->isValid())
                {
                    FMOD_RESULT result = system->loadBankFile(Common_MediaPath(BANK_NAMES[i]), FMOD_STUDIO_LOAD_BANK_NONBLOCKING, &data.banks[i]);
                    if (result != FMOD_OK)
                    {
                    }
                }
            }
        }
        if (Common_BtnPress(BTN_ACTION2))
        {
            // Unload all banks
            for (int i=0; i<BANK_COUNT; ++i)
            {
                FMOD_RESULT result = data.banks[i]->unload();
                if (result != FMOD_OK)
                {
                }
            }
        }
        if (Common_BtnPress(BTN_MORE))
        {
            wantSampleLoad = !wantSampleLoad;
        }
        // Load bank sample data

        for (int i=0; i<BANK_COUNT; ++i)
        {
            FMOD_STUDIO_LOADING_STATE bankLoadState = FMOD_STUDIO_LOADING_STATE_UNLOADED;
            FMOD_STUDIO_LOADING_STATE sampleLoadState = FMOD_STUDIO_LOADING_STATE_UNLOADED;
            if (data.banks[i] && data.banks[i]->isValid())
            {
                data.banks[i]->getLoadingState(&bankLoadState);
                data.banks[i]->getSampleLoadingState(&sampleLoadState);
            }
            if (bankLoadState == FMOD_STUDIO_LOADING_STATE_LOADED)
            {
                if (wantSampleLoad && sampleLoadState == FMOD_STUDIO_LOADING_STATE_UNLOADED)
                {
                    ERRCHECK(data.banks[i]->loadSampleData());
                }
                else if (!wantSampleLoad && (sampleLoadState == FMOD_STUDIO_LOADING_STATE_LOADING || sampleLoadState == FMOD_STUDIO_LOADING_STATE_LOADED))
                {
                    ERRCHECK(data.banks[i]->unloadSampleData());
                }
            }
        }


        ERRCHECK( system->update() );

        Common_Draw("==================================================");
        Common_Draw("Bank Load Example.");
        Common_Draw("Copyright (c) Firelight Technologies 2014-2014.");
        Common_Draw("==================================================");
        Common_Draw("Name              Handle  Bank-State  Sample-State");

        for (int i=0; i<BANK_COUNT; ++i)
        {
            FMOD_STUDIO_LOADING_STATE bankLoadState = FMOD_STUDIO_LOADING_STATE_UNLOADED;
            FMOD_STUDIO_LOADING_STATE sampleLoadState = FMOD_STUDIO_LOADING_STATE_UNLOADED;
            if (data.banks[i] && data.banks[i]->isValid())
            {
                data.banks[i]->getLoadingState(&bankLoadState);
                data.banks[i]->getSampleLoadingState(&sampleLoadState);
            }
            char namePad[64];
//.........这里部分代码省略.........
开发者ID:phametic,项目名称:GameEngineProject,代码行数:101,代码来源:load_banks.cpp


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