This commit is contained in:
bkaradzic 2013-08-06 21:04:28 -07:00
parent 3aea7306c6
commit f7fe163f2b
12 changed files with 67 additions and 70 deletions

View file

@ -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;
}

View file

@ -9,7 +9,6 @@
#include "entry_p.h"
#include <bx/countof.h>
#include <bx/uint32_t.h>
#include <bx/thread.h>
@ -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;

View file

@ -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);
}

View file

@ -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);

View file

@ -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;

View file

@ -57,7 +57,6 @@ namespace bgfx
#include <bx/bx.h>
#include <bx/debug.h>
#include <bx/blockalloc.h>
#include <bx/countof.h>
#include <bx/endian.h>
#include <bx/handlealloc.h>
#include <bx/hash.h>

View file

@ -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);

View file

@ -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

View file

@ -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)

View file

@ -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 )

View file

@ -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

View file

@ -7,7 +7,6 @@
#include <bx/debug.h>
#include <bx/hash.h>
#include <bx/uint32_t.h>
#include <bx/countof.h>
#include <bx/string.h>
#include "vertexdecl.h"