From 2aa7c9a14af6b2e675951e76f940f3b1107a2bf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= <branimirkaradzic@gmail.com> Date: Mon, 14 Mar 2016 23:32:37 -0700 Subject: [PATCH] Added error when bgfx::init is called without bgfx::setPlatformData. --- src/bgfx.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 7e1b72cd..c23d1fce 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2373,7 +2373,21 @@ namespace bgfx bool init(RendererType::Enum _type, uint16_t _vendorId, uint16_t _deviceId, CallbackI* _callback, bx::AllocatorI* _allocator) { - BX_CHECK(NULL == s_ctx, "bgfx is already initialized."); + if (NULL != s_ctx) + { + BX_CHECK(false, "bgfx is already initialized."); + return false; + } + + if (NULL == g_platformData.ndt + && NULL == g_platformData.nwh + && NULL == g_platformData.context + && NULL == g_platformData.backBuffer + && NULL == g_platformData.backBufferDS) + { + BX_CHECK(false, "bgfx platform data like window handle or backbuffer must be set."); + return false; + } memset(&g_caps, 0, sizeof(g_caps) ); g_caps.maxViews = BGFX_CONFIG_MAX_VIEWS;