|
@@ -1889,27 +1889,37 @@ namespace bgfx
|
|
|
|
|
|
|
|
bool Context::init(const Init& _init)
|
|
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 = _init;
|
|
|
m_init.resolution.reset &= ~BGFX_RESET_INTERNAL_FORCE;
|
|
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.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);
|
|
m_init.resolution.debugTextScale = bx::clamp<uint8_t>(_init.resolution.debugTextScale, 1, BGFX_CONFIG_DEBUG_TEXT_MAX_SCALE);
|
|
|
dump(m_init.resolution);
|
|
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) );
|
|
bx::memCopy(&g_platformData, &m_init.platformData, sizeof(PlatformData) );
|
|
|
|
|
|
|
|
m_exit = false;
|
|
m_exit = false;
|