Example Windows Launch Flow
April 27, 2023Less than 1 minute
Example Windows Launch Flow
Create Window
文件为:bgfx.cmake\bgfx\examples\common\entry\entry_windows.cpp
,入口函数如下:

在 Context::run
函数中创建Windows的窗口以及监听窗口事件,与此同时创建一个线程来开启 bgfx::entry::main
方法。
bgfxmain
该方法首先初始化以下模块:
- cmdInit
- input
- inputInit
- inputAddBindings
- windows info
然后启动entry::AppI
程序。
Launch entry::AppI
在自己的脚本里必须实现,以下函数:
int _main_(int _argc, char** _argv)
{
return 0;
}
可以直接在该函数里实例化一个应用,然后调用entry::runApp
,来启动应用。
如果已经实例化AppI
对象,启动AppI
有两种方式:
- 多个应用,使用命令行传入App名字来判断启动那个
- 一个时,直接运行
entry::runApp
entryinit
- 初始化宽度,调试等级...
- bgfx::init(init)
- bgfx::setViewClear(0...)
- imguiCreate()
entryshutdown
- imguiDestroy()
- bgfx::shutdown()
entryupdate
- entry::processEvents(...)
- bgfx::setViewRect(..)
- bgfx::touch(...): submit an empty primitive for rendering.
- commit frame buffer...
- bgfx::frame(): advance to next frame
- imguiBeginFrame()
- custom imgui...
- imguiEndFrame()