diff --git a/examples/common/entry_linux.cpp b/examples/common/entry_linux.cpp index 37422305..41007459 100644 --- a/examples/common/entry_linux.cpp +++ b/examples/common/entry_linux.cpp @@ -33,7 +33,7 @@ namespace entry static void initTranslateKey(uint16_t _xk, Key::Enum _key) { _xk += 256; - BX_CHECK(_xk < countof(s_translateKey), "Out of bounds %d.", _xk); + BX_CHECK(_xk < BX_COUNTOF(s_translateKey), "Out of bounds %d.", _xk); s_translateKey[_xk&0x1ff] = (uint8_t)_key; } diff --git a/examples/common/entry_windows.cpp b/examples/common/entry_windows.cpp index edf7d99d..6230609c 100644 --- a/examples/common/entry_windows.cpp +++ b/examples/common/entry_windows.cpp @@ -9,7 +9,6 @@ #include "entry_p.h" -#include #include #include @@ -47,7 +46,7 @@ namespace entry static uint8_t translateKeyModifiers() { uint8_t modifiers = 0; - for (uint32_t ii = 0; ii < countof(s_translateKeyModifiers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(s_translateKeyModifiers); ++ii) { const TranslateKeyModifiers& tkm = s_translateKeyModifiers[ii]; modifiers |= 0 > GetKeyState(tkm.m_vk) ? tkm.m_modifier : Modifier::None; diff --git a/examples/common/imgui/imgui.cpp b/examples/common/imgui/imgui.cpp index 76e7f1b1..1d7a4d21 100644 --- a/examples/common/imgui/imgui.cpp +++ b/examples/common/imgui/imgui.cpp @@ -399,7 +399,7 @@ struct Imgui drawText(_x + AREA_HEADER / 2 , _y + AREA_HEADER / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _name , imguiRGBA(255, 255, 255, 128) ); @@ -554,7 +554,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200) ); @@ -563,7 +563,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(128, 128, 128, 200) ); @@ -601,7 +601,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(255, 255, 255, 200) ); @@ -610,7 +610,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(128, 128, 128, 200) ); @@ -671,7 +671,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200) ); @@ -680,7 +680,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(128, 128, 128, 200) ); @@ -731,7 +731,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200) ); @@ -740,7 +740,7 @@ struct Imgui { drawText(xx + BUTTON_HEIGHT , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(128, 128, 128, 200) ); @@ -750,7 +750,7 @@ struct Imgui { drawText(xx + width - BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_RIGHT + , ImguiTextAlign::Right , _subtext , imguiRGBA(255, 255, 255, 128) ); @@ -776,7 +776,7 @@ struct Imgui m_widgetY += BUTTON_HEIGHT; drawText(xx , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , out , imguiRGBA(255, 255, 255, 255) ); @@ -791,7 +791,7 @@ struct Imgui drawText(xx + ww - BUTTON_HEIGHT / 2 , yy + BUTTON_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_RIGHT + , ImguiTextAlign::Right , _text , imguiRGBA(255, 255, 255, 200) ); @@ -889,14 +889,14 @@ struct Imgui { drawText(xx + SLIDER_HEIGHT / 2 , yy + SLIDER_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200) ); drawText(xx + width - SLIDER_HEIGHT / 2 , yy + SLIDER_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_RIGHT + , ImguiTextAlign::Right , msg , isHot(id) ? imguiRGBA(255, 196, 0, 255) : imguiRGBA(255, 255, 255, 200) ); @@ -905,14 +905,14 @@ struct Imgui { drawText(xx + SLIDER_HEIGHT / 2 , yy + SLIDER_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_LEFT + , ImguiTextAlign::Left , _text , imguiRGBA(128, 128, 128, 200) ); drawText(xx + width - SLIDER_HEIGHT / 2 , yy + SLIDER_HEIGHT / 2 + TEXT_HEIGHT / 2 - , IMGUI_ALIGN_RIGHT + , ImguiTextAlign::Right , msg , imguiRGBA(128, 128, 128, 200) ); @@ -1247,12 +1247,12 @@ struct Imgui return len; } - void drawText(int32_t _x, int32_t _y, imguiTextAlign _align, const char* _text, uint32_t _abgr) + void drawText(int32_t _x, int32_t _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _abgr) { drawText( (float)_x, (float)_y, _text, _align, _abgr); } - void drawText(float _x, float _y, const char* _text, imguiTextAlign _align, uint32_t _abgr) + void drawText(float _x, float _y, const char* _text, ImguiTextAlign::Enum _align, uint32_t _abgr) { if (!_text) { @@ -1260,11 +1260,11 @@ struct Imgui } uint32_t numVertices = 0; - if (_align == IMGUI_ALIGN_CENTER) + if (_align == ImguiTextAlign::Center) { _x -= getTextLength(m_cdata, _text, numVertices) / 2; } - else if (_align == IMGUI_ALIGN_RIGHT) + else if (_align == ImguiTextAlign::Right) { _x -= getTextLength(m_cdata, _text, numVertices); } @@ -1505,7 +1505,7 @@ bool imguiSlider(const char* _text, float* _val, float _vmin, float _vmax, float return s_imgui.slider(_text, _val, _vmin, _vmax, _vinc, _enabled); } -void imguiDrawText(int32_t _x, int32_t _y, imguiTextAlign _align, const char* _text, uint32_t _argb) +void imguiDrawText(int32_t _x, int32_t _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb) { s_imgui.drawText(_x, _y, _align, _text, _argb); } diff --git a/examples/common/imgui/imgui.h b/examples/common/imgui/imgui.h index 2cb49a10..4a5e0db0 100644 --- a/examples/common/imgui/imgui.h +++ b/examples/common/imgui/imgui.h @@ -26,17 +26,17 @@ #ifndef __IMGUI_H__ #define __IMGUI_H__ -enum imguiMouseButton -{ - IMGUI_MBUT_LEFT = 0x01, - IMGUI_MBUT_RIGHT = 0x02, -}; +#define IMGUI_MBUT_LEFT 0x01 +#define IMGUI_MBUT_RIGHT 0x02 -enum imguiTextAlign +struct ImguiTextAlign { - IMGUI_ALIGN_LEFT, - IMGUI_ALIGN_CENTER, - IMGUI_ALIGN_RIGHT, + enum Enum + { + Left, + Center, + Right, + }; }; inline uint32_t imguiRGBA(uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a = 255) @@ -71,7 +71,7 @@ void imguiLabel(const char* _format, ...); void imguiValue(const char* _text); bool imguiSlider(const char* _text, float* val, float vmin, float vmax, float vinc, bool _enabled = true); -void imguiDrawText(int _x, int _y, imguiTextAlign _align, const char* _text, uint32_t _argb); +void imguiDrawText(int _x, int _y, ImguiTextAlign::Enum _align, const char* _text, uint32_t _argb); void imguiDrawLine(float _x0, float _y0, float _x1, float _y1, float _r, uint32_t _argb); void imguiDrawRoundedRect(float _x, float _y, float _w, float _h, float _r, uint32_t _argb); void imguiDrawRect(float _x, float _y, float _w, float _h, uint32_t _argb); diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 3d0cc845..8185c61c 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -744,7 +744,7 @@ namespace bgfx memset(m_seq, 0, sizeof(m_seq) ); memset(m_seqMask, 0, sizeof(m_seqMask) ); - for (uint32_t ii = 0; ii < countof(m_rect); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_rect); ++ii) { m_rect[ii].m_width = 1; m_rect[ii].m_height = 1; diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 24572c5e..36dc511a 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -57,7 +57,6 @@ namespace bgfx #include #include #include -#include #include #include #include diff --git a/src/glcontext_glx.cpp b/src/glcontext_glx.cpp index 92a3ab92..4f757c72 100644 --- a/src/glcontext_glx.cpp +++ b/src/glcontext_glx.cpp @@ -82,7 +82,7 @@ namespace bgfx { BX_TRACE("---"); bool valid = true; - for (uint32_t attr = 6; attr < countof(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2) + for (uint32_t attr = 6; attr < BX_COUNTOF(attrsGlx)-1 && attrsGlx[attr] != None; attr += 2) { int value; glXGetFBConfigAttrib(s_display, configs[ii], attrsGlx[attr], &value); diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index aef66a92..555ed731 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -373,8 +373,8 @@ namespace bgfx { BX_TRACE("Adapter #%d", ii); - char description[countof(desc.Description)]; - wcstombs(description, desc.Description, countof(desc.Description) ); + char description[BX_COUNTOF(desc.Description)]; + wcstombs(description, desc.Description, BX_COUNTOF(desc.Description) ); BX_TRACE("\tDescription: %s", description); BX_TRACE("\tVendorId: 0x%08x, DeviceId: 0x%08x, SubSysId: 0x%08x, Revision: 0x%08x" , desc.VendorId @@ -478,37 +478,37 @@ namespace bgfx invalidateCache(); - for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii) { m_indexBuffers[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexBuffers); ++ii) { m_vertexBuffers[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_vertexShaders); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexShaders); ++ii) { m_vertexShaders[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_fragmentShaders); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_fragmentShaders); ++ii) { m_fragmentShaders[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_textures); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii) { m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_renderTargets); ++ii) { m_renderTargets[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_uniforms); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_uniforms); ++ii) { m_uniforms[ii].destroy(); } @@ -590,7 +590,7 @@ namespace bgfx void updateMsaa() { - for (uint32_t ii = 1, last = 0; ii < countof(s_msaa); ++ii) + for (uint32_t ii = 1, last = 0; ii < BX_COUNTOF(s_msaa); ++ii) { uint32_t msaa = s_checkMsaa[ii]; uint32_t quality = 0; @@ -2259,7 +2259,7 @@ namespace bgfx void Context::rendererUpdateViewName(uint8_t _id, const char* _name) { - mbstowcs(&s_viewNameW[_id][0], _name, countof(s_viewNameW[0]) ); + mbstowcs(&s_viewNameW[_id][0], _name, BX_COUNTOF(s_viewNameW[0]) ); } void Context::rendererUpdateUniform(uint16_t _loc, const void* _data, uint32_t _size) @@ -2864,8 +2864,8 @@ namespace bgfx tvm.printf(0, pos++, BGFX_CONFIG_DEBUG ? 0x89 : 0x8f, " " BGFX_RENDERER_NAME " "); const DXGI_ADAPTER_DESC& desc = s_renderCtx.m_adapterDesc; - char description[countof(desc.Description)]; - wcstombs(description, desc.Description, countof(desc.Description) ); + char description[BX_COUNTOF(desc.Description)]; + wcstombs(description, desc.Description, BX_COUNTOF(desc.Description) ); tvm.printf(0, pos++, 0x0f, " Device: %s", description); tvm.printf(0, pos++, 0x0f, " Memory: %" PRIi64 " (video), %" PRIi64 " (system), %" PRIi64 " (shared)" , desc.DedicatedVideoMemory diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index e688ff21..11ec631e 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -339,7 +339,7 @@ namespace bgfx D3DCREATE_SOFTWARE_VERTEXPROCESSING, }; - for (uint32_t ii = 0; ii < countof(behaviorFlags) && NULL == m_device; ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(behaviorFlags) && NULL == m_device; ++ii) { #if 0 // BGFX_CONFIG_RENDERER_DIRECT3D9EX DX_CHECK(m_d3d9->CreateDeviceEx(m_adapter @@ -473,37 +473,37 @@ namespace bgfx { preReset(); - for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii) { m_indexBuffers[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexBuffers); ++ii) { m_vertexBuffers[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_vertexShaders); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexShaders); ++ii) { m_vertexShaders[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_fragmentShaders); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_fragmentShaders); ++ii) { m_fragmentShaders[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_textures); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_textures); ++ii) { m_textures[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_vertexDecls); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexDecls); ++ii) { m_vertexDecls[ii].destroy(); } - for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_renderTargets); ++ii) { m_renderTargets[ii].destroy(); } @@ -532,7 +532,7 @@ namespace bgfx void updateMsaa() { - for (uint32_t ii = 1, last = 0; ii < countof(s_checkMsaa); ++ii) + for (uint32_t ii = 1, last = 0; ii < BX_COUNTOF(s_checkMsaa); ++ii) { D3DMULTISAMPLE_TYPE msaa = s_checkMsaa[ii]; DWORD quality; @@ -730,17 +730,17 @@ namespace bgfx capturePreReset(); - for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii) { m_indexBuffers[ii].preReset(); } - for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexBuffers); ++ii) { m_vertexBuffers[ii].preReset(); } - for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_renderTargets); ++ii) { m_renderTargets[ii].preReset(); } @@ -753,17 +753,17 @@ namespace bgfx capturePostReset(); - for (uint32_t ii = 0; ii < countof(m_indexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_indexBuffers); ++ii) { m_indexBuffers[ii].postReset(); } - for (uint32_t ii = 0; ii < countof(m_vertexBuffers); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_vertexBuffers); ++ii) { m_vertexBuffers[ii].postReset(); } - for (uint32_t ii = 0; ii < countof(m_renderTargets); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(m_renderTargets); ++ii) { m_renderTargets[ii].postReset(); } @@ -2196,7 +2196,7 @@ namespace bgfx void Context::rendererUpdateViewName(uint8_t _id, const char* _name) { - mbstowcs(&s_viewNameW[_id][0], _name, countof(s_viewNameW[0]) ); + mbstowcs(&s_viewNameW[_id][0], _name, BX_COUNTOF(s_viewNameW[0]) ); } void Context::rendererUpdateUniform(uint16_t _loc, const void* _data, uint32_t _size) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 7e044895..f27bdb96 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -1212,7 +1212,7 @@ namespace bgfx m_used[used] = Attrib::Count; used = 0; - for (uint32_t ii = 0; ii < countof(s_instanceDataName); ++ii) + for (uint32_t ii = 0; ii < BX_COUNTOF(s_instanceDataName); ++ii) { GLuint loc = glGetAttribLocation(m_id, s_instanceDataName[ii]); if (GLuint(-1) != loc ) diff --git a/src/renderer_gl.h b/src/renderer_gl.h index e8cdd728..295ee548 100755 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -650,12 +650,12 @@ namespace bgfx { void create() { - glGenQueries(countof(m_queries), m_queries); + glGenQueries(BX_COUNTOF(m_queries), m_queries); } void destroy() { - glDeleteQueries(countof(m_queries), m_queries); + glDeleteQueries(BX_COUNTOF(m_queries), m_queries); } void begin(uint16_t _id, GLenum _target) const diff --git a/src/vertexdecl.cpp b/src/vertexdecl.cpp index 697eb17d..8513629f 100644 --- a/src/vertexdecl.cpp +++ b/src/vertexdecl.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "vertexdecl.h"