mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-21 06:13:07 +01:00
Added headless validation for bgfx::init and bgfx::reset.
This commit is contained in:
38
src/bgfx.cpp
38
src/bgfx.cpp
@@ -1889,27 +1889,37 @@ namespace bgfx
|
||||
|
||||
bool Context::init(const Init& _init)
|
||||
{
|
||||
BX_ASSERT(!m_rendererInitialized, "Already initialized?");
|
||||
if (m_rendererInitialized)
|
||||
{
|
||||
BX_TRACE("Already initialized!");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_headless = true
|
||||
&& RendererType::Noop != _init.type
|
||||
&& NULL == _init.platformData.ndt
|
||||
&& NULL == _init.platformData.nwh
|
||||
&& NULL == _init.platformData.context
|
||||
&& NULL == _init.platformData.backBuffer
|
||||
&& NULL == _init.platformData.backBufferDS
|
||||
;
|
||||
BX_WARN(!m_headless, "bgfx platform data like window handle or backbuffer is not set, creating headless device.");
|
||||
|
||||
if (m_headless
|
||||
&& 0 != _init.resolution.width
|
||||
&& 0 != _init.resolution.height)
|
||||
{
|
||||
BX_TRACE("Initializing headless mode, resolution of non-existing backbuffer can't be larger than 0x0!");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_init = _init;
|
||||
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
|
||||
m_init.resolution.numBackBuffers = bx::clamp<uint8_t>(_init.resolution.numBackBuffers, 2, BGFX_CONFIG_MAX_BACK_BUFFERS);
|
||||
m_init.resolution.maxFrameLatency = bx::min<uint8_t>(_init.resolution.maxFrameLatency, BGFX_CONFIG_MAX_FRAME_LATENCY);
|
||||
m_init.resolution.maxFrameLatency = bx::min<uint8_t>(_init.resolution.maxFrameLatency, BGFX_CONFIG_MAX_FRAME_LATENCY);
|
||||
m_init.resolution.debugTextScale = bx::clamp<uint8_t>(_init.resolution.debugTextScale, 1, BGFX_CONFIG_DEBUG_TEXT_MAX_SCALE);
|
||||
dump(m_init.resolution);
|
||||
|
||||
if (true
|
||||
&& RendererType::Noop != m_init.type
|
||||
&& NULL == m_init.platformData.ndt
|
||||
&& NULL == m_init.platformData.nwh
|
||||
&& NULL == m_init.platformData.context
|
||||
&& NULL == m_init.platformData.backBuffer
|
||||
&& NULL == m_init.platformData.backBufferDS
|
||||
)
|
||||
{
|
||||
BX_TRACE("bgfx platform data like window handle or backbuffer is not set, creating headless device.");
|
||||
}
|
||||
|
||||
bx::memCopy(&g_platformData, &m_init.platformData, sizeof(PlatformData) );
|
||||
|
||||
m_exit = false;
|
||||
|
||||
Reference in New Issue
Block a user