Jump to content

[SOLVED] onExternalWindowRender event is not working on main rendering.


photo

Recommended Posts

Hello. 

We migrate engine to 2.18 from 2.16.

But  onExternalWindowRender function is not working on main rendering(otherwise splash's onExternalWindowRender is working)

createWindow is executed twice. OnExternalWindowRender is executed the first time, but onExternalWindowRender is not executed from the second createWindow.

spalsh's window and main's window handle is same.
 

        //! initialises the Direct3D API
        bool CUnigineEngine::initDriver(const core::dimension2d<int>& screenSize, HWND hwnd,
            UINT bits, bool fullScreen, bool pureSoftware, bool vsync,
            bool antiAlias)
        {
    
            m_KOVIEngine    = nullptr;

           const int argc = 13;        
            char* szValue[argc] =
            {
                "KoviArchiS.exe",        //default execute file 
                "-data_path",            // data path
                ".\\data",                //data folder name 
                "-video_app",
                "dx",
                "-engine_config",        // engine setting
                ".\\data\\unigine.cfg",
                //"-extern_package",
                //".\\data\\kovidata.ung",
                "-extern_define",        // user define 
                "MENU_USER,MOUSE_USER",
                "-extern_plugin",        // plug-in add
#ifdef _FBXEXPORT
                "FbxExporter,FbxImporter",
#else
                "FbxImporter",
#endif
                "-console_command",        // load world.
                "world_load \"basic_world_0.world\""        
            };

            systemProxyKovi.SetExtenalWindow(hwnd, this); //window main view

            scene::ISceneManager* pScenmgr = GetSceneManager();

            Unigine::Engine::InitParameters init_params;
            init_params.system_proxy = &systemProxyKovi;
            init_params.window_title = "temporary";

            this->m_KOVIEngine= Unigine::Engine::init(init_params, argc, szValue);

            return true;
        }

SystemProxyKOVI::SystemProxyKOVI() : CustomSystemProxy( SYSTEM_PROXY_MOUSE | SYSTEM_PROXY_KEYBOARD)
{

}

WIN_HANDLE  SystemProxyKOVI::createWindow(int width, int height)
{
    m_ExtenalMainWindow = std::make_shared< ExternalWindow>();

    WIN_HANDLE handle;
    handle.hwnd = m_hwnd;
    handle.win_id = (uint64_t)m_hwnd;

    registerExternalWindow(m_ExtenalMainWindow.get(), handle, Unigine::Math::ivec2(width, height));
    Unigine::Input::setEventsFilter(&SystemProxyKOVI::event_filter);
    return handle;
}

void SystemProxyKOVI::SetExtenalWindow(HWND hwnd, kvx::video::CUnigineEngine* pEngine)
{
    //m_ExtenalMainWindow = std::make_shared< ExternalWindow>();

    m_hwnd        = hwnd;
    //m_pEngine    = pEngine;
}

bool SystemProxyKOVI::registerExternalWindow(ExternalWindow* window, WIN_HANDLE win_handle,
    Math::ivec2 window_size)
{
    Unigine::Log::message("registerExternalWindow");

    //assert(window && !external_windows_.contains(window)
    //    && !external_id_to_window_.contains(win_handle.win_id));

    const Math::ivec2 valid_window_size = Math::max(window_size, Math::ivec2_one);
    if (0 == initExternalWindowBuffers(win_handle, valid_window_size))
    {
        return false;
    }

    external_windows_.push_back(window);
    external_id_to_window_.insert(win_handle.win_id, window);

    Engine::get()->getEventEndUpdate().disconnect(this, &SystemProxyKOVI::update_external_windows);
    Engine::get()->getEventEndUpdate().connect(endupdate_event_connections, this, &SystemProxyKOVI::update_external_windows);

    Engine::get()->getEventEndUpdate().disconnect(this, &SystemProxyKOVI::swap_external_windows);
    Engine::get()->getEventEndSwap().connect(endswap_event_connections, this, &SystemProxyKOVI::swap_external_windows);

    return true;
}

bool SystemProxyKOVI::registerExternalSubWindows(ExternalWindow* window, Unigine::WIN_HANDLE win_handle)
{
    return true;
}

bool SystemProxyKOVI::unregisterExternalWindow(ExternalWindow* window)
{
    assert(external_windows_.contains(window));
    if (!external_windows_.removeOne(window))
    {
        return false;
    }

    auto it_external_window = external_id_to_window_.findData(window);

    WIN_HANDLE win_handle;
    win_handle.win_id = it_external_window->key;
    shutdownExternalWindowBuffers(win_handle);
    external_id_to_window_.remove(it_external_window);

    return true;
}

bool SystemProxyKOVI::needRenderExternalWindow(WIN_HANDLE win_handle)
{
    bool result = false;
    const auto it = external_id_to_window_.find(win_handle.win_id);
    if (it != external_id_to_window_.end())
    {
        result = it->data->isRendering();
    }
    return result;
}

void SystemProxyKOVI::onExternalWindowRender(WIN_HANDLE win_handle)
{
    if (needRenderExternalWindow(win_handle))
    {
        const auto it = external_id_to_window_.find(win_handle.win_id);
        if (it != external_id_to_window_.end())
        {
            it->data->setEnableRender(m_bRender);
            it->data->doRender( window_size);
        }
    }
}

Link to comment

Hi Park,

Could you please share the whole project with reproduction? It's quite hard to understand what's going on here (especially part where you are passing window handle to engine window and later register the same window as external).

We can tell more after checking a complete test scene.

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

Thank you for your reply.
The problem was solved by implementing it in remove the boot screen. 
Have a good day.

  • Like 1
Link to comment
  • silent changed the title to [SOLVED] onExternalWindowRender event is not working on main rendering.
×
×
  • Create New...