From 7652b05cc51f8bf768ea449034116e48b3d6f353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 23 Feb 2015 11:33:02 -0800 Subject: [PATCH] Fixed GCC 4.9 type-limit warning. --- src/bgfx.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 3b9ac3c1..47f41b13 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -2628,66 +2628,73 @@ again: s_ctx->setClearColor(_index, _rgba); } + bool checkView(uint8_t _id) + { + // workaround GCC 4.9 type-limit check. + const uint32_t id = _id; + return id < BGFX_CONFIG_MAX_VIEWS; + } + void setViewName(uint8_t _id, const char* _name) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewName(_id, _name); } void setViewRect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewRect(_id, _x, _y, _width, _height); } void setViewScissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewScissor(_id, _x, _y, _width, _height); } void setViewClear(uint8_t _id, uint16_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewClear(_id, _flags, _rgba, _depth, _stencil); } void setViewClear(uint8_t _id, uint16_t _flags, float _depth, uint8_t _stencil, uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5, uint8_t _6, uint8_t _7) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewClear(_id, _flags, _depth, _stencil, _0, _1, _2, _3, _4, _5, _6, _7); } void setViewSeq(uint8_t _id, bool _enabled) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewSeq(_id, _enabled); } void setViewFrameBuffer(uint8_t _id, FrameBufferHandle _handle) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewFrameBuffer(_id, _handle); } void setViewTransform(uint8_t _id, const void* _view, const void* _projL, uint8_t _flags, const void* _projR) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewTransform(_id, _view, _projL, _flags, _projR); } void setViewRemap(uint8_t _id, uint8_t _num, const void* _remap) { BGFX_CHECK_MAIN_THREAD(); - BX_CHECK(BGFX_CONFIG_MAX_VIEWS == 256 || _id < BGFX_CONFIG_MAX_VIEWS, "Invalid view id: %d", _id); + BX_CHECK(checkView(_id), "Invalid view id: %d", _id); s_ctx->setViewRemap(_id, _num, _remap); }